#!/usr/bin/env perl use strict; use warnings; my $string = 'foo bar baz quux'; $string =~ /(\w+) (\w+) (\w+) (\w+)/; print "Numbered groups: $1 $2 $3 $4\n"; my @matches = ($1, $2, $3, $4); print "\@matches has @matches\n"; $3 =~ /^baz/; print "Numbered groups after match 2: $1 $2 $3 $4\n"; print "\@matches after match 2: @matches\n";