2009/6/10 Berler Chanan :
>
> In the real world (in my way of thinking)
> Foreach should have interpreted into a 'for' loop
>
> Means:
> foreach $elm (@elm_arr) ==> should have been: for ($index = 0; $index >=
> $#elm_arr; $index++) { $elm = $elm_arr[$index]; ..... }
>
> this way my script would have worked.
> Chanan
>
Or to be more precise:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
use strict;
use warnings;
my @arr = (1,2,3,4,5);
my $lv_num;
for ($lv_num = 0; $lv_num <= $#arr; $lv_num++)
{
print "Found $arr[$lv_num]\n";
last if ($arr[$lv_num] == 3);
}
print "arr[lv_num] = $arr[$lv_num]\n";
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Which works but in my eyes is not so pretty as using a foreach loop...
Regards,
--
Offer Kaye
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl