loris has asked for the wisdom of the Perl Monks concerning the following question:
Hello wiser ones,
How would I pass a regexp as a parameter to a subroutine? I would like to do something like:
changeName($topNodeOfXmlTree,'s/WrongNode/RightNode/');and have the function recurse through the XML tree and change, in my case, the node names:
sub changeNodeNames { my ($self,$node,$regEx) = @_; my $nodeName = $node->nodeName; $nodeName =~ $regEx; ...
The above, however, does not work.
Thanks for your help,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing regexp as argument
by Zaxo (Archbishop) on Dec 20, 2004 at 10:10 UTC | |
|
Re: Passing regexp as argument
by edan (Curate) on Dec 20, 2004 at 09:56 UTC | |
|
Re: Passing regexp as argument
by BUU (Prior) on Dec 20, 2004 at 16:34 UTC |