foreach my $filename ( @files ) { #for each filename in the array open(PHILE, '<', $filename) || die "cannot open $filename: $!"; #open file w/ error handling my @lines = scalar ; #get the Artist/Album info while ( ) { push @lines, $_ if /$bpm/; } if ( @lines > 1 ) { print @lines; } else { print "sorry, no matching BPMs found."; #deliver the bad news } close PHILE; #finish up }