in reply to Print the matched pattern

This example might help you.
#!/usr/bin/perl use strict; my $string = 'to test me'; $string =~ /to\s(\w+)\s/; print $1;
Please see perlre for more information specifically under capturing buffers.

Replies are listed 'Best First'.
Re^2: Print the matched pattern
by kingjamesid (Acolyte) on Oct 06, 2009 at 17:00 UTC
    Thanks. I didnt know, $1 is carried over. Dumb me though I thought about it. Thanks