[ale] PHP -> Perl

John Wells jb at sourceillustrated.com
Mon Apr 21 08:55:44 EDT 2003


Calvin,

My perl's a bit rusty, but I'll throw something out for Fletch to chop up ;).

$1, $2, etc. are only in scope for the enclosing block, so you need a way
to save those values after the while block.  If you evaluate the matching
operator in list context, it returns a list of backreferences, so you can
easily store those in variables...

I think this should work (warning...untested!):

while (! ( ($m1, $m2) = $retstr=~/^(\d+)\s+(\S+)$/ ) )
{
    #do stuff
}
$matches[0] = $m1;
$matches[1] = $m2;



Calvin Harrigan said:
> <PHP CODE>
> while(!preg_match("/^(\d+)\s+(\S+)$/", $retstr, $matches))
> {
>   #do stuff
> }



_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list