Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: $1 does not reset to undef

by keszler (Priest)
on Oct 25, 2013 at 11:31 UTC ( [id://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; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-03-19 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found