Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: $1 does not reset to undef

by keszler (Priest)
on Oct 25, 2013 at 11:31 UTC ( #1059623=note: print w/ replies, xml ) Need Help??


in reply to $1 does not reset to undef

As you noticed, $1 does not get set to undef on a failed match. The solution is to test the match:

use strict; use warnings; my @arry=( 'bond0.2 Link encap:Ethernet', 'bond4.3:6 Link encap:Ethernet', 'bond3 Link encap:Ethernet', 'bond5:0 Link encap:Ethernet', 'bond1.5:2 Link encap:Ethernet', 'bond2.6 Link encap:Ethernet' ); foreach (@arry) { if (/^([\w\.]+)\s+Link.*$/) { printf "Array item: %-30s\tmatch: %s\n",$_,$1; } }


Comment on Re: $1 does not reset to undef
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2015-07-28 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls