my @args = @ARGV; @ARGV = 'filename.txt'; my @found = grep { /^args[0]/ } <>;