use Getopt::Long; my $outfile = undef; my $configfile = undef; my $infile = undef; if( ! Getopt::Long::GetOptions( "outfile=s", \$outfile, "infile=s", \$infile, "configfile=s", \$configfile, "help", sub { print "Usage : $0 --configfile C [--outfile O] [--infile I] [--help]\n"; exit 0; }, ) ){ die "error, commandline" } die "configfile is needed (via --configfile)" unless defined $configfile; my $inFH = ; # read input from stdin by default, unless an in file is provided if( defined $infile ){ open $inFH, '<', $infile or die "opening input file $infile, $!"; } my $instr; {local $/ = undef; $instr = <$inFH> } if( defined ($infile){ close $inFH } # do similar for outfile and STDOUT ... # and call your module translate, input text is in $instr ...