If anyone has any clue why it only works correctly with that "print top" statement

Quite frankly, if your code does indeed work correctly with that "print top" statement, then I'd just leave that statement there. Then, I'd contact the Magic Circle and show it to them because they'd probably pay you a big lump of cash once they work out how it "works", because they'll be able to use for as the basis of some damn good illusions.

If you add use strict: to the top of your program and fix all these errors:

C:\test>perl -c junk8.pl Global symbol "$q1" requires explicit package name at junk8.pl line 16 +. Global symbol "$q2" requires explicit package name at junk8.pl line 17 +. Global symbol "$q1" requires explicit package name at junk8.pl line 18 +. Global symbol "$q2" requires explicit package name at junk8.pl line 18 +. Global symbol "%sockOpened" requires explicit package name at junk8.pl + line 31. Global symbol "%sockOpened" requires explicit package name at junk8.pl + line 31. Global symbol "%sockOpened" requires explicit package name at junk8.pl + line 32. Global symbol "$q1" requires explicit package name at junk8.pl line 34 +. Global symbol "$q2" requires explicit package name at junk8.pl line 35 +. Global symbol "%sockOpened" requires explicit package name at junk8.pl + line 40. Global symbol "%sockOpened" requires explicit package name at junk8.pl + line 40. Global symbol "$bytes" requires explicit package name at junk8.pl line + 46. Global symbol "%sockOpened" requires explicit package name at junk8.pl + line 46. Global symbol "$bytes" requires explicit package name at junk8.pl line + 49. Global symbol "$bytes" requires explicit package name at junk8.pl line + 53. Global symbol "$port" requires explicit package name at junk8.pl line +63. Global symbol "$port" requires explicit package name at junk8.pl line +68. Global symbol "$port" requires explicit package name at junk8.pl line +68. Global symbol "$port" requires explicit package name at junk8.pl line +69. Global symbol "$sockNumConn" requires explicit package name at junk8.p +l line 87. Global symbol "$sockNumConn" requires explicit package name at junk8.p +l line 114. Global symbol "$time" requires explicit package name at junk8.pl line +133. Global symbol "$time" requires explicit package name at junk8.pl line +134. junk8.pl had compilation errors.

You might get close to understanding some of your problems. The entire logic of your code is dependant upon this hash %sockOpened. You use it to direct the flow of your program all over the place:

$sockOpened{$fn}->close() if defined($sockOpened{$fn}); ... if (!defined($sockOpened{$fn}) && !open($sockOpened{$fn}, ">&$ +fn")) { ... $bytes = syswrite($sockOpened{$fn}, "$count/n", length($count) ++1, 0);

But you never declare that variable, and you never write to it, so what is it that you are testing?

I also suspect my scripts could be somewhat more compresses but I guess I've always been in the habit of being more verbose so both myself and others could better understand what I'm doing...

Sorry, but it doesn't seem to be working for you.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: Sharing sockets between the main script and thread by BrowserUk
in thread Sharing sockets between the main script and thread by markseger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.