rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a module installed in my computer (called XML::Parse), which I use for storing the recurrent functions, which I will be using in my scripts. One among the functions is thus:
sub parseinline { my $stag=0; my $etag=0; while ($_ =~ /<b>/g){$stag++} while ($_ =~ /<\/b>/g){$etag++} if ($stag != $etag){print "Mismatch between start and end element +for '<b>' in $ARGV[0]."} }
When I call this inside the script, it is working file:
use XML::parser; ... ... XML::parser->parsetag();
But, If I change this to the following to run for any tags mentioned during the run time, I am getting the output. I changed it as follows:
sub parseinline { my $stag=0; my $etag=0; while ($_ =~ /<$_[0]>/g){$stag++} while ($_ =~ /<\/$_[0]>/g){$etag++} if ($stag != $etag){print "Mismatch between start and end element +for '$_[0]' in $ARGV[0]."} }
and changed the script line to XML::parser->parsetag("b"); it is not working. Could someone suggest me a solution on how to use parameters when calling functions from the modules?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling a function with parameters from a Module
by pajout (Curate) on Jul 18, 2008 at 13:21 UTC | |
|
Re: Calling a function with parameters from a Module
by Anonymous Monk on Jul 18, 2008 at 13:16 UTC |