OK - so __FILE__ is the name of my script, but I will admit to not understanding what you're trying to do with it.

When I run your version of the BEGIN code, I get

Use of uninitialized value in string eq at /apps/bin/blah/reconcile_wi +thdotsh.pl line 68. main::BEGIN() called at /apps/bin/blah/reconcile_withdotsh.pl +line 73 eval {...} called at /apps/bin/blah/reconcile_withdotsh.pl lin +e 73
where lines 68 and 73 are:
67 BEGIN { 68 unless( $ENV{ +__FILE__ } eq __FILE__ ){ 69 delete $ENV{LIBPATH}; 70 $ENV{ +__FILE__ } = __FILE__; 71 exec $^X, __FILE__, @ARGV; # relaunch without LIBPATH 72 } 73}
It isn't __FILE__ that is the uninitialized value (as I put a print command in), so presumably its the "$ENV{ +__FILE__ }" but I can't manage to print that to check - and being in a BEGIN statement I can't step through it in debug.

Also, in both versions the script just ends (as opposed to terminating with an error).

Maybe I should be a heretic and go back to using COBOL on a mainframe! Do any still exist?

Cheers

Kev


In reply to Re^9: replicating the command 'unset LIBPATH' in perl by viffer
in thread replicating the command 'unset LIBPATH' in perl by viffer

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.