system($check . $elt); if (1 == $? >> 8) { chomp $elt; print blah blah; } #### 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