Paul Lalli wrote:
On Jul 5, 10:49 am, [EMAIL PROTECTED] (Monty) wrote:

    next unless /^(\S+)/;
    $who{$1}++;
}

It's the 'next' line I'm unclear on.  I know that results: parse the
first field from each output line of the 'who' command, but I'm
wondering why this might have been done in this way.  It seems to me
that the 'next' line states "get the next record unless the current
one startes with a non-whitespace character".

The UNIX 'who' command output lines always start with non-whitespace
characters, as far as I can see.  It seems just as sensible to leave
this line out.  Does anyone know additional value to doing this?

Well, the next command is actually doing three things at once.  First,
it's determining whether or not the current line starts with non-
whitespace characters.  Then, if it doesn't start with whitespace
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
EITHER:                               does start with whitespace
OR:                                   doesn't start with non-whitespace


characters, it skips the remainder of this iteration of the while
loop.  Finally, if it does start with whitespace characters, it's
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
EITHER:                 doesn't start with whitespace
OR:                     does start with non-whitespace


saving those characters in $1.


:-)

John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to