On Apr 27, 2004, at 5:39 AM, mike wrote:
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
Bookmarks