So, the problem is how can I count the number of time a caracter appears in a string. There is plenty of way, one of which is using y aka tr printf "\" appears %s times in this string\n", ($string)=~ y/"/"/;. For more info see the Categorized Questions and Answers.

This however, seems to be the least of your troubles. Who cares what lang HTML::Parser is implemented in? Are you writing a parser? Here's some code (i think you have a quesiton beyond "how to count the number of times a character appears in a string", but I dunno what it is):

#!/usr/bin/perl -w use strict; use HTML::TokeParser; my $string = qq, clear text <tag var1=".." var2="..>.." > clear text ,; printf "\" appears %s times in this string\n", ($string)=~ y/"/"/; my $p = HTML::TokeParser->new(\$string); die $! unless $p; while (my $token = $p->get_token) { # ["S", $tag, %$attr, @$attrseq, $origtext] if( ($token->[0] eq 'S') ) # is it a starting link tag { my ($typeotag, $tag, $attr, $attrseq, $origtext)=@$token; print "this start tag is ($tag)\n"; print "its attribues are (in original sequence):\n"; printf "(%s)=(%s)\n",$_,$attr->{$_} for(@$attrseq); print "\n\n-- a start tag no more --\n\n"; } else { printf "something else (%s)\n\t\t(%s)\n", @{$token}; } } __END__ F:\dev\HTML_Tokeparser_Tutorial>perl liar.pl " appears 4 times in this string something else (T) ( clear text ) this start tag is (tag) its attribues are (in original sequence): (var1)=(..) (var2)=(..>..) -- a start tag no more -- something else (T) ( clear text) something else (T) ( ) F:\dev\HTML_Tokeparser_Tutorial>

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


In reply to (crazyinsomniac) Re: parsing HTML by crazyinsomniac
in thread parsing HTML by eod

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.