On 8/7/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to count the number of lines in my output file processed by a > perl code. > > I am not getting the syntax correct. I am doing something like below:- > > my $count1 = `wc -l < $OUT_FILE` ; > print $LOG_FILE "Count of cdrs after removing duplicates = $count1" ; > > I am getting the following error: > [EMAIL PROTECTED] files]$ sh: -c: line 0: syntax error near unexpected token > `(' > sh: -c: line 0: `wc -l < GLOB(0x88f76d8)' > sh: -c: line 0: syntax error near unexpected token `(' > sh: -c: line 0: `wc -l < GLOB(0x88f76d8)' > > > Plz advice, > > Thanks, > Mihir >
That would be because $OUT_FILE is a file handle, not the file's name. You should also not be using the qx// operator (aka backticks) to do this, Perl can handle it just fine: sub count_words { my $file = shift; open my $fh, "<", $file or die "could not open $file:$!"; my $lines = 0; $lines++ while <$fh>; return $lines; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/