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.

so the following:

if($x =~ /pattern/){
        print "yes\n" if($y =~ //); ## this really means if($y =~ /pattern/)
if you made it this far
        }
__END__

man perlop; #line 1100
             If the PATTERN evaluates to the empty string, the
             last successfully matched regular expression is used
             instead.


-----Original Message-----
From: Jonathan E. Paton [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 1:29 PM
To: [EMAIL PROTECTED]
Subject: RE: reading one character at a time


> Is there a perl function that reads one character at
> a time from a string and and returns that character?

There are VERY FEW situations that require this kind of
action... but assuming you have one then the well proven
shortest approach is:

$string = "Hello World";
@string = $string =~ /./g;

OR:

$string = "Hello World";
for ($string =~ /./g) { print $_."\n"}

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!

Take care,

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to