You are absolutely correct, that the my is included inside the { } block. But that is
exactly where the confusion sets in, having had this problem when I started coding in
perl. The { } are required when using an if/else construct -- part of the syntax to
perform this function. Whereas a bloc
It works, but it prints nothing. You are basically dealing with 3 variable
here. the first 2 $date1 goes out of scope outside if {} else {}.
Simply move your declaration out of the if statement. That is:
my $date1 = "";
if ( your condition){
$date1=localtime;
}
else {
.
.
};
pr
On Apr 27, 2004, at 5:39 AM, mike wrote:
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;
an