Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^7: Problem with ampersand and regex

by davido (Archbishop)
on Dec 19, 2012 at 22:09 UTC ( #1009646=note: print w/ replies, xml ) Need Help??

in reply to Re^6: Problem with ampersand and regex
in thread Problem with ampersand and regex

Well, that does tell us that you're not chomping the input, which you should be doing. chomp @array; would take care of that problem. What it doesn't show me is how the following would fail:

my @array = ( 'sn ThisUser', 'mail:', 'cn: This User', 'uid: MyUID', ); foreach my $line ( @array ) { if( $line =~ m/^mail:\s+([\S]+)/ ) { print "$1\n"; } }

It doesn't fail on my system, which leads me to believe that the problem is in a portion of your code that we're not seeing, or in your data-set. If your data-set looks clean, we're back to the portion of the code that we haven't been shown.


Comment on Re^7: Problem with ampersand and regex
Select or Download Code
Replies are listed 'Best First'.
Re^8: Problem with ampersand and regex
by Anonymous Monk on Dec 20, 2012 at 14:24 UTC
    Thank you for your time Dave in going to this much effort to help a total stranger. Not sure exactly what fixed it, but I used the chomp as recommended and then copied/pasted your code and that seems to have solved the issue.

    Thanks again and have a great Christmas!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009646]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2015-10-07 17:57 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (194 votes), past polls