if (@ARGV) { # something's in @ARGV so we'll use it use open ':raw'; # implicit binmode on each open open(ARGV, shift @ARGV); # Yeah, it's the two-arg version, # because that's what perl does with <> # see perlopentut } else { # nothing's in @ARGV so we'll use STDIN use open ':raw'; # implicit binmode on each open open(ARGV, '-'); } # ... now go do all that sysread stuff.