use strict;
my $str = '# model: pmy0_footr015
filedependancy Unknown
newmodel pmy0_footr015
setsupermodel pmy0_footr015 NULL
classification Character
setanimationscale 1.0
beginmodelgeom pmy0_footr015
node dummy pmy0_footr015
parent NULL
endnode
node trimesh pmy0_footr015g
parent pmy0_footr015
position 0.0 0.0 0.0
orientation 1.0 0.0 0.0 0.0
bitmap pmh0_footr050
verts 15
-0.0378169 -0.00381612 0.00857995';
my $regex = qr/model: ([^\n]+)(.*)bitmap [^\n]+/msp;
my $subst = 'model: $1$2bitmap $1';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html