sub match_url { my $row = shift @_; while ($row =~ /$re/g) { say "$&"; } } if ( !@ARGV || $ARGV[0] eq "-") { @ARGV = ; chomp(@ARGV); match_url(@ARGV); } else { # Do I need to handle the error case with this syntax? while (<>) { chomp $_; match_url($_); } }