#! perl -slw use strict; sub func{ my $arg = shift; my $fh; if( -e $arg ) { open $fh, '<', $arg or die $!; } else { $fh = $arg; } ## do stuff }