DDH has asked for the wisdom of the Perl Monks concerning the following question:
my $mystring = "test"; my $temp2 = $mystring; if ($temp2 =~ m/^[a-zA-Z]+$/) { $naam = $1; } else { die "Wrong input"; } print "Het woord is $1"; my $uur = 24; my $temp1 = $uur; if($temp1 < 25 && $temp1 =~ /\d\d/) { $uur = $1; } else { die "Geen correcte tijdsduur. Niet meer dan 24 uren ingeven!!"; } print "$uur";
I have two if statements the second if i check if the number is less then 24 when this is true then $uur = $1. And i Think that $1 is the first variable that is in the memory or something like that?
The first if is exactly the same but there i check if the string consists of the caracters a-zA-Z if this is true then $naam = $1 but when i print the variable $naam it has nog value. Can someone explain this?
20050413 Janitored by Corion: Added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A memory problem?
by prasadbabu (Prior) on Apr 13, 2005 at 14:10 UTC | |
|
Re: A memory problem?
by RazorbladeBidet (Friar) on Apr 13, 2005 at 14:13 UTC | |
|
Re: A memory problem?
by tlm (Prior) on Apr 13, 2005 at 14:12 UTC |