use constant DEFAULT_FILE => "/etc/filesystems"; my $file = shift || DEFAULT_FILE; # e.g. to take file from command line or use the default find_pattern($file, $pattern); sub find_pattern { my ($file, $pattern) = @_; # your code here } #### ... die "oh no, it's not there!" unless find_pattern($file, $pattern); sub find_pattern { my ($file, $pattern) = @_; return `grep $pattern $file`; }