Looking in the File::MMagic source, I see this (edited for relevance):
use vars qw( $dataLoc ); sub new{ $dataLoc = $fh->tell() if (! defined $dataLoc); }
Question: since $dataLoc is a package-scope variable and will only be initialized once, would this cause problems when forked?

I wrote some quick and dirty sample code which does, indeed go wrong if I use File::MMagic. I assume Anonymous Monk is using use. If I require File::MMagic after the fork, it seems to work fine.

So, question to Monks-more-experienced-than-I: What happens to package variables when you fork?

Russ
Brainbench 'Most Valuable Professional' for Perl


In reply to RE: File::MMagic Woes (Fork and use vars) by Russ
in thread File::MMagic Woes by Anonymous Monk

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.