Thanks for the help. That did it, now if I could ask one more question on this. How can I make the MS portion match either upper or lower case?
-----Original Message----- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Monday, August 16, 2004 12:01 PM To: 'Chris Devers'; Fontenot, Paul Cc: [EMAIL PROTECTED] Subject: RE: pattern extraction Chris Devers wrote: > On Mon, 16 Aug 2004, Fontenot, Paul wrote: > > > Here is the entire script: > > Thanks, this is clearer. > > > while (my(@row) = $sth->fetchrow_array) > > { > > # ... snip ... > > my $mso = $row[2](m/MS\d\d\-\d{3}/); > > This may work better: > > my $mso = $row[2] =~ (m/MS\d\d\-\d{3}/); > > or > > my $mso = ( $row[2] =~ (m/MS\d\d\-\d{3}/) ); It should be: my ($mso) = $row[2] =~ /(MS\d\d-\d\d\d)/; > > I'm cargo culting here, i.e. pasting an idiom that I've never > understood as clearly as I ought to; I can never keep straight when > (or why) the pattern match should be wrapped in parens, but I think > the latter version should definitely work. Both versions will set $mso to true/false depending on success of the match. To capture the actual value matched, you need to use parens in the regex and call in list context. The parens around $mso force the m// operator into context. (Chris, why do all your messages have an X-Message-Flag header? It's annoying for poor shlubs like me who are using MS Outlook :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>