"Romeyn, Derek" wrote:

> K, I tried this and it didn't work as expected:
>
>         $code =~ / HTTP\/\d\.\d\" (\d+)/;
>         if (!$code) {
>                 print "NEXT\n";
>                 next;
>         }
>         print "$code\n";
>
> The loop just printed NEXT 300 or so times.  I was thinking that $code would
> equal whatever was in the parentheses.  Am I still not getting this?

Probably not.  The code did exactly what you told it to do.  It printed the string 
'NEXT", followed by a newline.  Presumably you have this code inside a loop which runs 
300 or so times, as there is nothing in the code posted that would make it loop.

Is there some reason you expected the bare string NEXT to hold some value?  Did you do 
anything to assign a value to it?

As to the regular expression, try:
perldoc perlre

The parentheses capture values, which will remain until the next time a regex is used, 
in the form:
$1, $2 ... $n where n is equal to. the number of matches found.  In this context, 
$role is the string being tested.

Always read the manual before trying to use a sophisticated tool.

Joseph



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

Reply via email to