Jeff Westman wrote:
>
> Hi,
Hello,
> 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)"
Use the special <> operator, it will automagically read from command
line files or pipes.
while ( <> ) {
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]