[Israel.pm] Can anyone explain my mistake ?

Berler Chanan bc.other at gmail.com
Wed Jun 10 02:53:18 PDT 2009


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: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] 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
Perl at perl.org.il
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



More information about the Perl mailing list