j3 has asked for the wisdom of the Perl Monks concerning the following question:
I've just begun poking around the nms scripts, and am seeing something odd (to me) at the end of some of their files.
The files in question (guestbook.pl, for example) end with a long BEGIN block. I'm hoping someone here can explain a few details about what it's doing. Here's a sample (taken from guestbook.pl, edited for brevity):
(Edit: removed readmore tags)
#/usr/bin/perl -wT # ... {snip regular stuff (code + some POD)} ... # ... {and now, at the end of the file} BEGIN { eval 'local $SIG{__DIE__} ; require CGI::NMS::IPFilter'; $@ and $INC{'CGI/NMS/IPFilter.pm'} = 1; $@ and eval <<'END_CGI_NMS_IPFILTER' || die $@; ## BEGIN INLINED CGI::NMS::IPFilter package CGI::NMS::IPFilter; use strict; + require 5.00404; + use Socket; # ... {snip code interspersed with POD} ... 1; ## END INLINED CGI::NMS::IPFilter END_CGI_NMS_IPFILTER CGI::NMS::IPFilter->import(); }
Now, there seems to be a number of things going on here, a couple of which I might even understand :) :
What's the most common way of handling this situation, where you want either the installed module first, or else the one that you're including in your distribution? I've heard the term ``Orcish maneuver'', but I guess this is more of an ... hmm... maybe ``or just use this one here'' (the Ojutoh defense? ).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Odd convention? (fall-back module in BEGIN block)
by kyle (Abbot) on Feb 15, 2007 at 21:10 UTC | |
by j3 (Friar) on Feb 15, 2007 at 21:22 UTC | |
by chromatic (Archbishop) on Feb 15, 2007 at 22:22 UTC | |
|
Re: Odd convention? (fall-back module in BEGIN block)
by Anonymous Monk on Feb 15, 2007 at 21:06 UTC | |
|
Re: Odd convention? (fall-back module in BEGIN block)
by Anonymous Monk on Feb 15, 2007 at 21:05 UTC | |
by j3 (Friar) on Feb 15, 2007 at 22:38 UTC | |
by ikegami (Patriarch) on Feb 15, 2007 at 23:08 UTC |