Hi,

I am trying to get my script to be able to read from the command line
arguments as well as take input from a pipe.  This is what I have basically:

#----------------------- (begin) --------------------#
#!/bin/perl
use warnings;

sub parseFile()
{
    while (<F>) {
        # do some processing to the file
        #  ...
    }
}

if (@ARGV) {
    # this part works fine
    $file = shift;
    open(F, "< $file") or die "cannot open file $file: $!\n";
    parseFile(\*F);
    close(F);
}
else {
    # trying to read from a pipe, such as 'cat file | thisScript.pl'
    parseFile(\*STDIN);
}

#----------------------- (end) --------------------#

When I run this, as in 'cat myFile | thisScript.pl', I get:
Too many arguments for main::parseFile at ./x line 16, near "*F)"
Too many arguments for main::parseFile at ./x line 21, near "*STDIN)"

Help please.

Jeff



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to