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.