Hi, I have an instance of HTML::TokenParser::Simple, I need to copy it, go to the next token in my copied version, then go back to my original (none incremented version). The problem is when I go to the next token in my copied version it does the same to my original verison. Any ideas?
#!/usr/bin/perl -w use HTML::TokeParser::Simple; my $p = HTML::TokeParser::Simple->new("clean.htm"); my $token = $p->get_token; #$token = $p->get_token; #$token = $p->get_token; print "1 " . $token->as_is . "\n"; my $p_blah = $p; print "2 " . getNextToken($p_blah) . "\n"; $token = $p->get_token; print "3 " . $token->as_is . "\n"; sub getNextToken { if(my $token_blah = $_[0]->get_token){ return $token_blah->as_is; } else { return "end"; } }
returns
1 <p class=label> 2 Business insurance 3 </p>
when I expected
1 <p class=label> 2 Business insurance 3 Business insurance

In reply to HTML::TokeParser::Simple copying? by craigmarksmith

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.