in reply to Passing regexp as argument
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.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 } );
|
|---|