Please check your script for syntax errors:
$ perl -c script.pl
syntax error at /tmp/test.pl line 45, near "if"
syntax error at /tmp/test.pl line 61, near "}"
$
some comments upon your code.
- whole code: a clear indentation would help reading and debugging the code! perltidy can help with this!
- line 31: why do you use s/// here? m// should do the job!
The replacement of > (at the beginning of the string) is not needed here as you split the string and use the second part. So why do you remove the >?
- line 42: %positions is a Hash-of-Arrays; why are you trying to dereference it as a Hash-of-Hashes?
- line 44: what's that single @? Maybe you want to dereference the array reference in $positions{$key}? If so, you still should rename $value to $position!
- What do you think $value is for, as you don't use it in your for-loop.
- line 49: why are you still comparing a string length with an array reference?
- I stopped analyzing the following lines. But it looks like as you are not aware about what you have stored in $positions{$key}
As tilly already mentioned, you should start learning about perl's complex data structures. Recommended documentation:
Update:
- comment on line 42 added.
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.