Hi,
Looking at the script below, why does the while function loop 6 times instead 
of 3 times when @data have only 3 elements and 
I thought the output should be:- 
1 $_ = aaa    1 
2 $_ = bbb    2
3 $_ = ccc    3

Thanks

#############################

#!/usr/bin/perl
use strict;
use warnings;

my @data = ('aaa 1','bbb 2','ccc 3');
my $ctr = 0;

print "There are ",scalar @data," elements in \...@data\n";

while (<@data>){
 $ctr ++;
 print "$ctr \$_ = $_\n";
}

Reply via email to