Getoptions (...); $input = "-" unless defined $input; open my $fh => $input or die $!; while (<$fh>) { ... }