#!perl use 5.012; # Populate @ARGV unless files are specified on the command line @ARGV = grep { -f } glob('/tmp/files/*') unless @ARGV; while (<>) { chomp; if ( m/map/i ) { # The name of the current file is in the special variable $ARGV say "$_ in $ARGV"; } }