[tpm] adding an INIT block via the command line

Fulko Hew fulko.hew at gmail.com
Fri Oct 24 10:56:18 PDT 2014

On Fri, Oct 24, 2014 at 1:16 PM, John Macdonald <
john.malcolm.macdonald at gmail.com> wrote:

> How about:
>     perl -e "INIT { code }; do $filename"

Close, but no cigar.
I forgot about 'do', but although your suggestion does indeed run the INIT,
it doesn't seem to be happening at the right time.

But I've figured out my own solution... below...

What I was really trying to do is get a list of all the modules, my various
applications use.

   Because I have a corporate 'scan of code looking for GPL and other
license violations'
   happening. And the stuff they're 'commercial tool' found was no where
near the
   list of dependencies I have.
   So _I_ want to give them the real list. (Yes I realize I'm opening
myself up
   for a potentially bigger attack.)

   In some of my other apps, I've already built in a 'dependant module list
   option [so that for those sites that are isolated and can't have access
to CPAN,
   they can run my app with the option to get the list of the dependencies,
   resolve it 'the hard way... manually'.]

   The routine I use (but needs to be run at the right time) is:

     print join("\n", sort grep { /^[A-Z]/ } map { s|/|::|g; s|\.pm$||; $_
} keys %INC), "\n"; exit;

But I was looking for an EASY way to prepend that functionality to all my
other apps,
without having to edit them all.

The solution I now have is to create a seperate package/module/file that

package CCC;

   print join("\n", sort grep { /^[A-Z]/ } map { s|/|::|g; s|\.pm$||; $_ }
keys %INC), "\n";


and then invoke my apps with:
   perl -I. -mCCC ./myapp.pl

That now gives me my whole hierarchy of dependencies.


> On 24 October 2014 13:07, Fulko Hew <fulko.hew at gmail.com> wrote:
>> A hopefully quick question...
>> I have a bunch of programs, and I'd like to do a test on where I execute
>> each
>> program, but before it actually 'does stuff', but after its done all of
>> its
>> 'use' statements, it runs my 2 lines of code.
>> Sort of doing a:
>> perl -e INIT { code } filename
>> but a -e prevents the running of filename!
>> I want to do both.
>> Suggestions anyone ?
>> _______________________________________________
>> toronto-pm mailing list
>> toronto-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/toronto-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20141024/fc26a4b9/attachment.html>

More information about the toronto-pm mailing list