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?


In reply to Calling a function with parameters from a Module by rsriram

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.