Re: [Nolug] Crappy Perl Code

From: Mark A. Hershberger <mah_at_everybody.org>
Date: Sun, 13 Jul 2003 00:56:21 -0500
Message-ID: <87isq7ezqy.fsf@everybody.org>

Alex McKenzie <alex@boxchain.com> writes:

> That was my introduction to Perl. I had to glue some really crappy
> Perl to some baddish Perl, and it really really turned me off to the
> language. A lot of assumptions were made in both scripts, and it
> wasn't apparent becase there was no documentation (not a fault of the
> language) and because it was so terse.

Can't blame you. But, as I continually learn, experience is not
normative. My introduction to Perl was totally different.

> BTW, in trying to further understand the use of $_ adn _, I went to
> perldoc. I've been looking around for a while, because when I tried
> to search for it, I get:

For _, see perlfunc(1):

   If any of the file tests (or either the ""stat"" or ""lstat""
   operators) are given the special filehandle consisting of a
   solitary underline, then the stat structure of the previous file
   test (or stat operator) is used, saving a system call. (This
   doesn't work with ""-t"", and you need to remember that lstat() and
   ""-l"" will leave values in the stat structure for the symbolic
   link, not the real file.) (Also, if the stat buffer was filled by
   a ""lstat"" call, ""-T"" and ""-B"" will reset it with the results
   of ""stat _"").

An example follows this in the documentation.

For $_, see perlvar(1):

  $ARG
  $_ The default input and pattern-searching space. The
          following pairs are equivalent:

          while (<>) {...} # equivalent only in while!
          while (defined($_ = <>)) {...}

          /^Subject:/
          $_ =~ /^Subject:/

          tr/a-z/A-Z/
          $_ =~ tr/a-z/A-Z/

          chomp
          chomp($_)

HTH,

Mark.
___________________
Nolug mailing list
nolug@nolug.org
Received on 07/13/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST