Alex Rivera | Logout

How can I find all matches to a regular expression in Perl?

Asked 2009-11-12T16:18:46.663
29

I have text in the form:

Name=Value1
Name=Value2
Name=Value3

Using Perl, I would like to match /Name=(.+?)/ every time it appears and extract the (.+?) and push it onto an array. I know I can use $1 to get the text I need and I can use =~ to perform the regex matching, but I don't know how to get all matches.

Edit
Report

1 Answer

1

Use a Config:: module to read configuration data. For something simple like that, I might reach for ConfigReader::Simple. It's nice to stay out of the weeds whenever you can.

answered 2009-11-12T20:17:17.337

Your Answer