dvergin has asked for the wisdom of the Perl Monks concerning the following question:
Reading through some well-distributed code I found this near the top of the main script:
Now, although I have never seen the little meme in that BEGIN block before, I understand what it is doing. (That's not the question.) My question is this: "is this a Good Practice?" What is the point?use lib qw(./include); use Cwd; # avoid needing to refer to SnortSnarf packages as SnortSnarf::*, even + if # that is where they really are: sub BEGIN { push(@INC,map("$_/SnortSnarf",grep(-d "$_/SnortSnarf",@INC +))); } use SnortFileInput; use HTMLMemStorage; use HTMLAnomMemStorage; use SnortRules; etc. etc.
So far as I can see, this bit of source-hiding simply saves a few keystrokes near the top of the file. And if done to access it could lead to some maintainance annoyances. Imagine adding several module paths to @INC and then trying to find the modules later: "Let's see, I wonder if the module referred to in 'use Parser' is XML::Parser or HTML::Parser..."
It's cute. It's slick. But is it Good?
David
Update: Thanks to the responders below for confirming my misgivings. I'm open to learn new approaches, but this one felt wrong from the get-go.