Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Source code in Inlined zip file

by zentara (Archbishop)
on Dec 23, 2013 at 18:04 UTC ( [id://1068231]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, I saw in a Python script called youtube-downloader, that all the modules and main script code were all condensed into an inline zip file, which would be automatically decompressed by the Python Interpreter. It's first few lines would look like this:
#!/usr/bin/env python PK^C^D^T^@^@^@^H^@B...^Q^X'^@^@..^@^@^\^@^\^@youtube_dl/FileDo +wnloader.pyUT ^@^C..fQ%zfQux^K^@^A^D.^C^@^@^D.^C^@^@.=.w.Fr... &#1 +555;.^B.)Xv.k......

I've since learned that you can unzip it manually if you cut'n'paste properly.

So does Perl have a way of doing this? I thought is was a cool feature.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re: Source code in Inlined zip file ( pp -P -o out.pl -x infile.pl )
by Anonymous Monk on Dec 24, 2013 at 04:43 UTC
Re: Source code in Inlined zip file
by LanX (Saint) on Dec 23, 2013 at 18:18 UTC
    dunno about a ready to use module for that, but putting the compressed code after __DATA__ and uncompressing it in a one-liner shouldn't be too difficult and not much longer.

    But there was a module to pack modules into one file ... others will certainly remember the name! =)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re: Source code in Inlined zip file
by ateague (Monk) on Dec 23, 2013 at 19:25 UTC
    Isn't this what PAR::Packer et al. does?
Re: Source code in Inlined zip file
by bhildred (Novice) on Dec 24, 2013 at 04:23 UTC
    This Should be easy to do as a source filter, I started one but didn't like that it was less friendly to standard tools.
Re: Source code in Inlined zip file
by aitap (Curate) on Dec 27, 2013 at 17:25 UTC

    There is also App::FatPacker which packs all (pure-perl) dependencies into a text file which does not require decompressing before reading.

    You might want to check out App::Staticperl, an application to build a standalone Perl executable with necessary modules and code to run included (like perlcc on steroids, uses C code in the middle stage, too).

    Edit: removed some wrong info about PAR

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1068231]
Approved by LanX
Front-paged by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found