-
Notifications
You must be signed in to change notification settings - Fork 47
View the data in a piddle a la Data::Dumper
Zakariyya Mughal edited this page Jan 5, 2015
·
3 revisions
Sometimes you want to just view the data in piddle, but you don't have PDL::IO::Browser installed. What to do? From Craig DeForest comes this gem. It only looks like a piece of barbed wire, but it is even sharper.
sub bigstring {
my($pdl, $fmt, $lev) = @_;
$fmt = "%g" unless($fmt);
my $s=" "x$lev;
if($pdl->ndims > 1) {
$s .= join("\n", "[", (map { bigstring($_,$fmt,$lev+1) } dog $pdl), $s."]");
}
elsif ($pdl->ndims) {
$s .= "[ " . join(" ",map { sprintf($fmt,$_) } $pdl->list) . " ]";
}
else {
$s = sprintf($fmt,$pdl->at(0));
}
return $s;
}
print bigstring($bighonkingpdl,"%5g");