in reply to Passing regexp as argument

The others before me have answered the exact question you asked, namely how you pass a regex, but if you want a slightly more flexible solution (and better than a string eval), you should consider passing a subreference, which you then call to modify node name. For your code above would look like:
sub change_node_names { my ($self, $node, $code) = @_; $nodeName = $code->( $nodeName ) } $foo->change_node_names( $node, sub { my $name = shift; $name =~ s/wrongnode/rightnode/; return $name } );
While this requires slightly more effort to call the subroutine, it is much more flexible as you can put literally *any* perl code inside of the annonymous sub, which is what the funnny  sub { } creates.