Ramprasad A Padmanabhan wrote:
I want to write a perl script like "gnu less".

My perl script accepts input on STDIN or filename(s) as arguments. If both are missing it should print the error message. How do I do this
? The pseudocode will be


----------
IF     INPUT ON STDIN  ;then
   Process STDIN

ELSE IF ARGUMENT(S) is a file ;then
   Process content of file(s)

ELSE Show usage / help message

END IF ------------

Any ideas how this can be done in perl ?

if ( not @ARGV and -t STDIN ) { die "No file found"; }

while ( <> ) {
    process_files_or_stdin();
    }



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to