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 drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2014-10-23 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (128 votes), past polls