Hello Monks, After using the XML::Parser module I've encountered a problem. I seem to get a result which is confusing. So is there any way to find out which row I'm currently in? I would think that the expat string which I get (XML::Parser::Expat=HASH(0x819a53c)) might tell that, but I didn't see any reference to it in perldoc.

I used the parser like this. The file I'm parsing is 161M gzipped so no snippets of data here.
# field we want my $FIELD = 'comment'; my $TEXT = 'text'; # flag && stuff my $com = ""; my $text = 0; my %UNIQ; my $i = 0; my $str = ""; sub start (@) { shift @_; if ($_[0] eq $FIELD) { $com = $_[2]; } elsif ($com ne "" && $_[0] eq $TEXT) { $text = 1; } } sub end (@) { shift @_; if ($_[0] eq $FIELD) { $com = ""; # $i=0; $str = ""; } elsif ($_[0] eq $TEXT) { $text = 0; } } sub text (@) { # shift @_; if ($text && $_[1]=~/\S/) { # $UNIQ{$com}{$_[1]}++; # $i++; if ($str) { print "$_[0]\n'$str','$_[1]'\n$com\n";exit;} $str .= $_[1]; } } my $parser = new XML::Parser(Handlers => { Start => \&start, End => \&end, Char => \&text, }); $parser->parse(*STDIN);

In reply to XML::Parser problems by Hena

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.