unshift(@ARGV, '-') unless @ARGV; while ($ARGV = shift) { open(FRED, $ARGV); binmode(FRED); while () { ... # code for each line } #### use open IN => ':raw'; while (<>) { # code for each line }