What is the slickest way to programatically read from stdin or an input file (if provided) in Perl?
This provides a named variable to work with:
foreach my $line ( ) { chomp( $line ); print "$line\n"; }
To read a file, pipe it in like this:
program.pl < inputfile