I have the following sub that creates a log file using Data::Dumper.
It also lists the name of each of the variables that it’s fed. It works great
except for one problem - every line is appended with “ = undef;” (minus the
quotes).
I’ve tried stripping it out of $var_value with regex but that doesn’t
work, so it appears that Data::Dumper is adding that text during the print
command.
Does anyone know how I can eliminate that extra text from being
printed? My searches have come up empty.
Thanks,
Frank
--------------------------------------------
datadump('log_name', '>>',
"database $database",
"matches $matches",
"image $image",
);
sub datadump {
my $filename = shift;
my $write = shift;
my @var_info = @_;
no strict;
open(my $log, $write, "temp_logs/TESTS-$filename.log");
use Data::Dumper;
foreach my $var (@var_info) {
my @vars = split (/,/ => $var);
my $var_name = '$'.$vars[0];
my $var_value = $vars[1];
print {$log} Data::Dumper->Dump( [$var_value], [$var_name] );
$count++;
}
close($log);
use strict;
}
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/