#!/usr/bin/perl # vi: set ts=4 sw=4 sts=2 et: use strict; use warnings; my $text = q~a b c d a b c d~; $text =~ s/([ab])/&show_what($1)/ge; print $text, $/; sub show_what { my $match = shift; print "matched: $match", $/; return $match x 2; } __END__