in reply to Counter && print issue

foreach $i ($elt)

You have to declare a counter outside of the loop and increment it when needed. Also, that code will run only once since foreach expects a list and $elt isn't one. Thus, there's no need to count anything. What about (untested):

system($check . $elt); if (1 == $? >> 8) { chomp $elt; print blah blah; }

If, on the other hand, $elt is a reference to an array, you may be wanting something along this lines:

my $count; foreach $i (@$elt) { # @$elt is an abbreviation of @{$elt} -- see + perlreftut system($check . $i); # using $i instead of $elt if (1 == $? >> 8) { chomp $i; print blah blah; # use $i here $count++; } } ## use $count here

UPDATE: Typo fixed "$@" -> "@$". Thanks to Errto.

--
David Serrano