http://www.perlmonks.org?node_id=530176

rmexico has asked for the wisdom of the Perl Monks concerning the following question:

is there a way to get a regex to return an array of instances? for ex.
undef $/; open INFILE, "<$file"; my @filecontents = <INFILE>; close INFILE; foreach my $filepieces (@filecontents) { if ($filepieces =~ /SOME_REGEX/smg) { # do something w/ match }
BUT --- what if that regex occurs more than once in the file? it'll match and stop at that instance. how do i get to more occurrances of what i'm hunting for if i'm slurping the whole file into a variable?