How do I do something like 'print Dumper $var' in Embperl - I did this:
[-
$var = (some hash) ;
use Data::Dumper
print Dumper $var
-]
and this
[+ Dumper $var +]
...but couldn't get any output.
I usually use Data::Dumper's Dump
method, which produces a string I can do anything I want with.
[! use Data::Dumper; # Only need to do once !]
[-
$var = (some hashref);
print Data::Dumper->Dump([$var, \@var2, \%var3]);
# Note that Dump takes an arrayref of SCALARs, therefore
# if you have arrays/hashes, you need to pass references to those
-]
HOWEVER, please remember that in EmbPerl, you need to be careful where you print:
To print to Apache's error log, print to STDERR:
[-
print STDERR Data::Dumper->Dump([$var, \@var2, \%var3]);
-]
To print to your web page, print to OUT
handle, or use [+ +]
includes. If it's a debug print, I usually just stick it inside an HTML comment:
<!-- DEBUG
[+ Data::Dumper->Dump([$var, \@var2, \%var3]); +]
[- print OUT Data::Dumper->Dump([$x1, $x2], ["VarName1", "VarName2"]); -]
-->