* John W. Krahn <[EMAIL PROTECTED]> [2008-06-27 11:28]:
> Tim Bowden wrote:
>> On Tue, 2008-06-24 at 19:37 -0700, John W. Krahn wrote: 
>>>
>>> Perhaps:
>>>
>>> my ( $snippet ) = $string =~ /\w\["([^"]+)",/;
>>
>> $string =~ /\w\["([^"]+)",/;
>> my $snippet = $1;
>>
>> does the trick.  I can see If I don't get on top of regex's I'm
>> seriously restricting the power of perl.  Starting to understand them
>> better now.
>
> You shouldn't do that.  If you use the value of a numeric variable without 
> verifying that the regexp matched successfully then the value in the 
> numeric variable could be the result of a previous successful match.

That's a GREAT point John but how can you verify that the regexp matched 
successfully ?

How do you know that the $1 does NOT come from your last regexp, you can't 
undefine it BEFORE you use it ?

-- 
      _        Jerry Rocteur    [EMAIL PROTECTED]                               
                                                    
    _|_|_                   http://www.rocteur.cc                               
                                                    
    (0 0)                   MSN [EMAIL PROTECTED]                               
                                                    
ooO--(_)--Ooo      Jabber [EMAIL PROTECTED]                                     
                                              
_________________________________________________ 
[06:23:57 rocteur.cc /Users/jerry]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to