Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: accumulating rex-exp matches in an array

by japhy (Canon)
on Jun 25, 2002 at 18:27 UTC ( #177167=note: print w/replies, xml ) Need Help??


in reply to accumulating rex-exp matches in an array

You should never use a regex variable without making sure the regex matched. If a line DIDN'T contain "AAA.n", $1 would retain its value!

Anyway, you want to use the /g modifier:

while (<INFILE>) { push @list, /AAA.\d/g; # parens not needed in regex here }

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2021-01-27 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?