I am getting a bit confused here, if I uncomment out the print statement
within the if block $date1 prints, however the $date1 after the if block
doesn't
if ($date eq ''){ my $date1=localtime; #print $date1; } else { my $date1=~$date; }; print $date1;
any ideas
my(...) scopes a variable locally, which usually means it ceases to exist at the next }, or end of the block. If you need the same variable through and outside a block, you have to declare it outside:
my $date1;
if ($date eq '') { $date1 = localtime; }
else { $date1 = $date; } # not what you had, but I bet it's what you meant
print "$date1\n";
While we're talking, you should look into adding the following two lines to the top of all your code:
use strict; use warnings;
This would have kept the code you posted from compiling and it would have told you why. Build good habits.
Good luck.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>