Hi,
was trying to reproduce the code below.
I was wondering what the 1 is doing before the while. Is it the exit
status of the while, that is until eof is reached and exit code = 1 ?

thanks,
radhika

>      If you're not reading from any other files, you don't need the
> $count
>      variable in this case. The special variable $. holds the number of
>      lines read since a filehandle was last explicitly closed:
>
>          1 while <FILE>;
>          $count = $.;
>
>      This reads all the records in the file and discards them.
>
> But if you really do need to do this via a system command -- you don't,
> but I'll play along -- then the command as you've given it is what is
> known as a Useless Use Of Cat.
>
> This command --
>
>      cat file | wc -l
>
> -- is equivalent to this one --
>
>      wc -l file
>
> -- but the latter invokes less overhead, and so should be a bit faster.
>
> Unless you really are conCATenating a chain of files together, most
> commands of the form "cat foo | cmd" can be rewritten as "cmd foo" or,
> maybe, "cmd < foo".
>
>
>
> --
> Chris Devers      [EMAIL PROTECTED]
> http://devers.homeip.net:8080/blog/
>
> np: 'It's Not Easy Being Green (lo-fi midi version)'
>       by Kermit
>       from 'The Muppet Movie Soundtrack'
>
>
>
>
> Chris,
>
> You are exactly right, that is a useless use of cat, old habits die
> hard. And of course you are correct in that it can be done entirely in
> perl, the availability of the shell cmd wc makes us lazy, and we don't
> want to code what we can just call from the system.
>
> Chris Hood
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


-- 
It's all a matter of perspective. You can choose your view by choosing
where to stand.
Larry Wall
---

-- 
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