earlati2 has asked for the wisdom of the Perl Monks concerning the following question:

I need to release an embedded revision of perl,

which means that I need to release only my custom module plus the modules on which it depends.

There are some way to get the list of  the perl  modules and files strctly required by my applications ?

Regards, Enzo

 

Replies are listed 'Best First'.
Re: retailed (embedded) perl
by cdarke (Prior) on Sep 06, 2006 at 10:01 UTC
    For modules, list the keys of the %INC hash (values give the full path name).
    If runing on *nix, strace(1) or truss(1) are handy for finding the names of files opened. With strace use: strace -e trace=open to trace all file open calls. Note that some library (.so) calls are expected to fail, you can ignore these. Check man pages for argument details.
    I don't know of an equivalent on Windows, the dependency walker will not know about DLLs loaded at runtime (using LoadLibrary).
    Hope this helps. update Sorry, strace example should be:
    strace -e trace=open perl scriptname.pl
      thanks strace -e trace=open perl scriptname.pl is a good help to detect dependencies
Re: retailed (embedded) perl
by BrowserUk (Patriarch) on Sep 06, 2006 at 10:11 UTC

    If you're on Win32, see StraceNT or Process Explorer both of which can provide this information. The latter is easier to use IMO.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: retailed (embedded) perl
by zentara (Cardinal) on Sep 06, 2006 at 11:56 UTC
    Try this:
    #!/usr/bin/perl #BEGIN { unshift @INC, sub { warn "loading $_[ 1]\n"; return } } #or use lib sub {warn "loading $_[ 1]\n"; return }; use CGI; print "hello\n"; #or #Abigail #Alternatively, one could just inspect %INC. #Just stuff # CHECK {print "$_\n" for keys %INC} #somewhere in your code, and run 'perl -c'.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      Your is a really interesting solution.
      I tested both
      BEGIN { unshift @INC, sub { warn "loading $_ 1\n"; return } }
      use lib sub {warn "loading $_ 1\n"; return };
      and it works,
      but is not clear to me why sub is executed each time
      perl scan directories for find an use module
      can you explain me more aboute this feature ?
      Regards, Enzo

        In addition to paths, @INC can contain code refs (and a couple of other things). When trying to load a module, Perl iterates over @INC until the module is loaded. If a path is encountered, Perl looks for the module in that directory. If a code ref is encoutered, Perl calls the code ref with the name of the module to load.

        The snippet places a code ref at the @INC's head, causing it to be called first. When called, it displays the name of the module Perl is attempting to load. It doesn't load the module, so Perl proceeds with the next entry in @INC.

        References: @INC, require

        can you explain me more aboute this feature ?

        What do you think I am.... a Saint? :-)

        I just had that from an earlier post by some Saint like abigail..... it's magic. :-)


        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: retailed (embedded) perl
by ides (Deacon) on Sep 06, 2006 at 14:24 UTC
    Why not use PAR? It should just magically do everything you need without any real work on your part.

    Frank Wiles <frank@revsys.com>
    www.revsys.com

Re: retailed (embedded) perl
by chromatic (Archbishop) on Sep 06, 2006 at 17:35 UTC
      very usefull
      tanks