in reply to Unexpected output for given program with write function

I think you'll do better with a post that requires a lot less code. Asking strangers -- even kindly ones like (some of) the Monks -- to scrub 400 lines of code is a bit much.

OTOH, in the spirit of Charity (it seems to be paying its decennial visit) and despite the fact this isn't the root of your problem, use strict; use warnings would tell you that:

Use of comma-less variable list is deprecated at F:\_wo\_perl\pl_test\ +909098.pl line 43. ... Use of comma-less variable list is deprecated at F:\_wo\_perl\pl_test\ +909098.pl line 101.

I'm running 5.12, and too lazy to check the delta to see when the deprecation began, so maybe your perl won't produce that series, but you should check, anyway.

And, though again not the cause of your problem, $my_var1 and $my_var2 are not declared before use in the 390s (Note: my line numbers are offset from your by about 5 or 6).

And -- Charity not yet satisfied (well, neither am I) and still urging kindness -- the construct at your 391 - 394 is a tad suspect; an if with ONLY an else. Your script seems to arrive here with the conditional in a false value, suggesting you focus on your compare sub... but even Charity is exhausted now.

Give her a break; if attacking the issue with debug is too hard, insert some (more) print statements to test conditions at various points in your script... and then submit a boiled down version -- 10 to 20 lines -- which illustrates the failure, assuming that hasn't illuminated your understanding.

Replies are listed 'Best First'.
Re^2: Unexpected output for given program with write function
by dipesh777 (Novice) on Jun 10, 2011 at 14:43 UTC
    Thank you very much, this the first post ever i made and i am so gad that the issue is solved very quickly. i will use this forum for ever.. And also will follow your advice. Thanks once again.