in reply to Re^2: Regex substitute matches second match first?
in thread Regex substitute matches second match first?

The /g modifier is for global matches. For instance, if you had numerous IPs on a single line, and you wanted to grab them all. eg: (untested)

my $line = "1.1.1.1 blah 2.2.2.2"; my @ips = $line =~ /\d+\.\d+\.\d+\.\d+/g;

Now $ips[0] would be '1.1.1.1' and $ips[1] would contain '2.2.2.2'.

A couple of docs you can review are perlretut and perlre.

Replies are listed 'Best First'.
Re^4: Regex substitute matches second match first?
by Linicks (Scribe) on May 25, 2016 at 17:33 UTC

    Thanks for your help, will read up

    Nick