in reply to Filehander Question

So, erm, do that. Read perldoc perlopentut and perldoc -f open. Read the docs for Getopt::Std or Getopt::Long. If you're given a filename, open a handle on it; if not, dup STDOUT.

my $fh; if( $filename ) { # open file, put handle in $fh } else { # dup STDOUT, put handle in $fh } print $fh "wubba wubba\n"; close( $fh ); exit( 0 );

Update: expanded the exercise-for-the-reader comments some.