On Thu, Sep 30, 2004 at 11:26:27AM -0500, Errin Larsen wrote:
> When I run your command line up there, I get the following:
>
> # perl -MO=Deparse -l00pe's/\n/\t/;s/\"//g'
> LINE: while (defined($_ = <ARGV>)) {
> chomp $_;
> s/\n/\t/;
> s/"//g;
> }
> continue {
> print $_;
> }
> -e syntax OK
>
> What OS are you running? My '-MO=Deparse' didn't create that BEGIN
> Block. I'm on Solaris, using Perl 5.6.1. I'm just curious what the
> difference is.
That was on linux, but the important thing here is the perl version.
5.6.1 is old, and if you are looking at the B modules (which Deparse is)
it's very old. There have been many improvements (bug fixes) since
then.
> --Errin
>
> BTW, I didn't know about the Deparse Pre-Compiler thing! Thanks for
> pointing it out. It's very handy. Why do you think Perl uses:
>
> while( defined( $_ = <ARGV> ) )
>
> instead of:
>
> while( <> )
>
> Is this example pointing out that the diamond ( <> ) operator is
> really a short-cut for 'defined( $_ = <ARGV> )' ?
Yes, exactly that.
> I'll have to go
> read about this. What is Perl protecting against by putting that
> assignment in a defined()?
It's protecting against input which evaluates to false, such as the last
line of a file which contains only 0 and no newline, for example.
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>