Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^4: Problem with ampersand and regex

by Anonymous Monk
on Dec 19, 2012 at 21:23 UTC ( #1009638=note: print w/replies, xml ) Need Help??

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

I get ? ?

Replies are listed 'Best First'.
Re^5: Problem with ampersand and regex
by davido (Archbishop) on Dec 19, 2012 at 21:48 UTC

    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.


      Done and here is a sample of what I got back:
      ', 'sn: ThisUser ', 'mail: ', '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:', '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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009638]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-06-19 01:53 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.