The code outputs:#!/usr/bin/perl use strict; my $count=0; my @cp_op = "111 222 333"; foreach my $line (@cp_op) #splits each line of the array { print "$line\n"; $count ++; } print "$count\n";
Why does count only increment once instead of 3 times, once for each line??? Please help111 222 333 1
20091208 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
In reply to Counter in foreach loop by RustyShackelford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |