--- Mike Ring <[EMAIL PROTECTED]> wrote:
> I've learned a bit about regular expressions today. I have a string
> formatted
> like "CN=foo,OU=bar,O=pah" and I need to parse out "foo". I have
> created the
> following code which does work:
> 
> $dnvalue =~ m/([^,]*)/;
> $username = $1;
> $username =~ s/(CN=)//;
> print $username
> 
> However, I'd like to do the match/replace on a single line. Can
> anyone show me
> how to combine these statements into a more elegant regular
> expression?

 my ($cn) = $dnvalue =~ /^CN=([^,]*),/;

The list context provided by the parens around $cn will make the match
return the value found. =o)

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to