> -----Original Message-----
> From: Shishir K. Singh [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 26, 2002 12:26 PM
> To: bob ackerman; [EMAIL PROTECTED]
> Subject: RE: extracting a string from between parens
> 
> 
> 
> On Wednesday, June 26, 2002, at 08:48  AM, Shishir K. Singh wrote:
> 
> >> $out = $1 if ($in =~ /\((.*?)\)/);
> > Nope..won't work..I take it back!!
> >
> 
> >looks ok to me. except it adds extra strokes to previous answer.
> >what do you think is wrong with it?
> 
> It will work fine as far as the regex is concerned. I think 
> what Todd may want is to check the $out for defined or 
> undefined. This line won't give him the same kind of validation. 
> 
> 
> Perhaps..he should be doing it this way
> 
> $in =~ /\((.*?)\)/;
> $out = (defined($1) ? $1 : "default/undef/whatever??";

Sorry, still not right. defined($1) is no better than $1 alone after
a failed match.

Again, the most straightforward solution is:

  ($out) = $in =~ /\((.*?)\)/;

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

Reply via email to