in reply to $1 in variable regex replacement string

This works.
#!/usr/bin/perl -w use strict; my $str = 'abcadefaghi'; my $pat = '(a.)'; my $repl = sub {"$1 "}; $str =~ s/$pat/&$repl/eg; print "$str\n"; # prints: '$1 c$1 ef$1 hi'

-enlil