in reply to Counter in foreach loop

Further to jwkrahn's reply:
You can find the number of elements in an array by evaluating the array in scalar context (also note that printing an array 'element' demarcated by something like single-quotes in a piece of debug code like this shows each element more clearly):

>perl -wMstrict -le "my $count=0; my @cp_op = '111 222 333'; print 'elements in array: ', scalar @cp_op; foreach my $line (@cp_op) { print qq{'$line'}; $count ++; } print qq{$count}; " elements in array: 1 '111 222 333' 1

Also: Please update your original post to wrap your code in  <code> ... </code> or  <c> ... </c> tags. Please see Markup in the Monastery.