Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I've been using <> for years to read STDIN, but have not found a good way to document my code for others to use.
I want to do something like this (but it doesn't work :) ):my @lines; foreach my $line (<>) { chomp($line); push(@lines,$line); } if ($#lines<0) { &usage(); } else { #Process STDIN.... } sub usage { printf "This is how to use this script....\n"; die(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to use <> responsibly?
by rjt (Curate) on Jul 24, 2013 at 17:12 UTC | |
|
Re: How to use <> responsibly?
by jeffa (Bishop) on Jul 24, 2013 at 17:09 UTC |