Just a few comments (since I don't really know what algorithm you are trying to implement). First consider using
using strict and warnings. And next, on this line:
for(my $i=$m;$i<scalar @a;$i++)
A more "perlish" way of doing that sort of thing is:
for my $i ($m..$#a)
And this:
while (($key1, $val1) = each(%num))
{
push(@key,$key1);
push(@val,$val1);
}
}
Is easier done like this (and they will be in the correct corresponding order):
my @key = keys %num;
my @val = values %num;
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.