did you mean
if ($packets[$i] =~ /$str/) {?
The only thing that I see with this is if there's multiple instances of $str in $packets
$i, the hash counter won't be incremented correctly. If I leave the /g in, my matches won't happen because pos is past the start of a match.
For example, I have ABC and I check (and match the substring AB). This means that pos points at C now. If I go through again and try to match the substring BC, it won't find it.
Maybe I've misunderstood what you were suggesting here. Correct me if necessary.
As far as the solution you provided, I haven't tried it yet. To be completely honest, I'm just trying to get myself into the groove of learning the minor nuances of Perl, and I have very little idea of what parts of your code are doing. Fear not, though - I am going through it bit by bit with my Camel book at hand, and hopefully in the next day or two I'll feel confident enough to run it. I'd like to at least be able to tweak things if I need to and know what I'm doing! :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.