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

RE: reading one character at a time

Thread Previous | Thread Next
Jonathan E. Paton
March 4, 2002 11:20
RE: reading one character at a time
Message ID:
 --- Nikola Janceski <> 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

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About