in reply to Re: Counting the start and end elements in a line
in thread Counting the start and end elements in a line

When I call the function

counttags(+);

When the script is compiled, I get a error,

Syntax error at vtag.pl at line 275, near "+)"
Execution of vtag.pl aborted due to compilation errors.

On the otherhand, if I have the code as counttags("+");, the $stag and $etag values remain 0.

For you to understand better, the content in the file goes like:
Die Errichtung <I>einer</I> Zweigniederlassung ist durch die Geschäftsführer anzumelden. Der Anmeldung ist eine öffentlich beglaubigte Abschrift des Gesellschaftsvertrages und der Liste der Gesellschafter beizufügen.<+>2</+>

In my function, I am trying to find the number of <I> and </I>, <+> and </+> and check whether the opening and the closing tag count matches.

Replies are listed 'Best First'.
Re^3: Counting the start and end elements in a line
by davorg (Chancellor) on Jun 27, 2006 at 12:13 UTC

    When I call the function

    counttags(+);

    When the script is compiled, I get a error,

    Syntax error at vtag.pl at line 275, near "+)"
    Execution of vtag.pl aborted due to compilation errors.

    Yes. That's what I expected. You can't just drop an operator in the middle of some source code at random and expect the compiler to know what to do.

    On the otherhand, if I have the code as counttags("+");, the $stag and $etag values remain 0.

    This is probably because of one of the other errors that have been pointed out to you in this thread. Developing with use strict and use warnings will almost certainly help you track down problems like this.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg