develooper Front page | perl.beginners | Postings from March 2002

RE: reading one character at a time

Thread Previous | Thread Next
From:
Jonathan E. Paton
Date:
March 4, 2002 11:20
Subject:
RE: reading one character at a time
Message ID:
20020304192036.59340.qmail@web14609.mail.yahoo.com
 --- Nikola Janceski <nikola_janceski@summithq.com> wrote:
> actually searching on a empty pattern is wrong wrong
> wrong!  A pattern in a search that evalutes to "" will
> use the previous successful pattern match.

Lets see what I actually said:

| Split on a null length string is probably more
| readable, but this simple technique works for pairs
| of characters... and allows you to avoid pack() and
| unpack() a little longer!

Did I say empty pattern?  No... so you can't assign me
those wrongs.  Besides, this works fine:

local $_ = "Hi There";

if (/Hi/) {
    print join "-", (split //);
}

which is the opposite of what you implied.  The reason
is that for // the default regex is the previous
expression... but for split the default is a single 
space character.  Split behaves differently from a
normal regex function.

[See page 795 of 3rd Ed. Programming Perl] 

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About