# sub signature:
# insertXintoYatZ( X , Y , Z ) ;
sub insertXintoYatZ{
my ( $X , $Y , $Z ) = @_;
substr( $Y , $Z , -length($Y) ) = $X ;
return $Y;
}
$s = "The black cat climbed the green tree";
print "s = $s \n";
print 'insert = '.($s = insertXintoYatZ( "tall ", $s , 26 ))."\n";
print " (now, s = '$s' ) \n";
# OUTPUT:
# s = The black cat climbed the green tree
# insert = 'tall '
# (now, s = 'The black cat climbed the tall green tree' )";
|