Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Problem with ampersand and regex

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


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

Add the following to your script:

use Data::Dumper;

...and then on the line immediately preceding your "for" loop, add, "print Dumper \@array;".

There might be something broken in your input data, and that would be a simple means of identifying (or eliminating) it as a problem.


Dave

Replies are listed 'Best First'.
Re^6: Problem with ampersand and regex
by Anonymous Monk on Dec 19, 2012 at 22:01 UTC
    Done and here is a sample of what I got back:
    ', 'sn: ThisUser ', 'mail: ThisUser@somewhere.com ', 'cn: This User ', 'uid: MyUID
    Now what?

      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: ThisUser@somewhere.com', '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.


      Dave

        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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009643]
help
Chatterbox?
[stevieb]: I've finally added the ability for berrybrew to fetch the list of perls available directly from Strawberry's releases.json file. Instead of pulling from there on every single call, I've added a berrybrew fetch, so it's only updated..
[stevieb]: ...on request. There's some supporting work I need to do, as well as update the docs, but it's in the v1.12 branch if anyone wants to play with it...
[stevieb]: ...issue 62 will track what else needs to be done.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-03-31 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (364 votes). Check out past polls.