try doing this:
sub {
while ...
}
Look for the removed "()" around the declaration for sub, and u won't tell the sub
that it takes no arguments.
-Sharad
-----Original Message-----
From: Jeff Westman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 24, 2003 3:23 PM
To: beginners
Subject: Reading from STDIN from a pipe
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]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]