Jeff 'Japhy' Pinyan wrote: > On Sep 9, Kevin Pfeiffer said: > >>In article <[EMAIL PROTECTED]>, David wrote: >> >>[...] >>> [panda]$ html.pl >>> no input >>> [panda]$ html.pl file.html >>> get file file.html >>> [panda]$ echo "hi" | html.pl >>> get line hi >>> [panda]$ >>> >>> perldoc -f select >>> perldoc IO::Select >> >>Thanks! This is what I was thinking of; I'll take a look. > > I really that's too much work. The -t file test should be sufficient: > > if (@ARGV) { > # getting input via command-line arg > $html = shift; > } > elsif (-t STDIN) { > # STDIN is the user's terminal (as opposed to a piped stream) > usage(); > } > else { > # the user has piped us something > $html = join "", <STDIN>; > } > > See 'perldoc -f -X' for more details. >
Jeff, your version only checks to see is STDIN is attached to a tty. for example, run your script from a crontab and you see will it never prints the usage. (ie, it always thinks that there is something to work with even there isn't any). david -- $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$"; map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#, goto=>print+eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]