Fix for my issue although I can't understand the scope issue is
(I would have consider this as a bug)
Thanks
Chanan
my @arr = (1,2,3,4,5);
my $lv_num = 0;
foreach $lv_check_num (@arr)
{
print "Found $lv_check_num\n";
if ($lv_check_num == 3)
{
$lv_num = $lv_check_num;
Last;
}
}
print "lv_num = $lv_num\n";
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Berler Chanan
Sent: Wednesday, June 10, 2009 11:53 AM
To: 'Perl in Israel'
Subject: Re: [Israel.pm] Can anyone explain my mistake ?
If I correct the script like this:
I get this result: I get lv_num = 0 ????? why not 3
Weird to me....thought it will update the number correctly
Chanan
my @arr = (1,2,3,4,5);
my $lv_num = 0;
foreach $lv_num (@arr)
{
print "Found $lv_num\n";
last if ($lv_num == 3);
}
print "lv_num = $lv_num\n";
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Berler Chanan
Sent: Wednesday, June 10, 2009 11:48 AM
To: 'Perl in Israel'
Subject: [Israel.pm] Can anyone explain my mistake ?
Hi All
I am running this simple foreach loop:
why do I get lv_num = <null> ? am I missing something ?
Thanks
Chanan
my @arr = (1,2,3,4,5);
foreach $lv_num (@arr)
{
print "Found $lv_num\n";
last if ($lv_num == 3);
}
print "lv_num = $lv_num\n";
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.56/2161 - Release Date: 06/09/09
18:08:00
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.56/2161 - Release Date: 06/09/09
18:08:00
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl