Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: Split() first 3 elements of @array

by ig (Vicar)
on Aug 28, 2012 at 20:40 UTC ( #990331=note: print w/replies, xml ) Need Help??

in reply to Re^2: Split() first 3 elements of @array
in thread Split() first 3 elements of @array

I cannot sxtract the IP address for the switch for some reason

The third line, with the IP address is indented: there is some whitespace at the beginning of the line, but your regular expression is looking for 'IP' at the beginning of the line: /^IP/. Change that to accept some leading whitespace and you should get a match: /^\s*IP/

Replies are listed 'Best First'.
Re^4: Split() first 3 elements of @array
by Kenosis (Priest) on Aug 28, 2012 at 20:48 UTC
    use Modern::Perl; use Modern::Perl; say ' IP address:' =~ /IP\s+address:\s+([^\s]+)/; say 'IP address:' =~ /IP\s+address:\s+([^\s]+)/; say ' IP address:' =~ /^\s*IP\s+address:\s+([^\s]+)/; say 'IP address:' =~ /^\s*IP\s+address:\s+([^\s]+)/;


    Update: Ah! hmb104 was referring to using split, not the regex (which isn't attempting to match at the beginning of a line and is fully anchored w/o mentioning the spaces before "IP address:").

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990331]
[Discipulus]: oh the thread is going on while I was reading the history of a left-handed pitcher.. finding no cue..
[karlgoethebier]: Discipulus: Jenda waits for his rapture? Ja, ja..
[karlgoethebier]: is waiting for his magic carpet...
[karlgoethebier]: ...but it doesn't come
[Discipulus]: I referring also to support denmark one, no the enoch one (Roma is in champion league anyway ;=)
[Discipulus]: anyway me too i wonder if your sig is appropriate: sigs remain while CB is volatile: for example i have even more problem with hungary president..

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-06-22 11:52 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.