I have seen, in the dim and distant path, text files distributed in the form of a shell script that creates all the files. I'd like to do that in a perl script, so here's my first attempt. This is designed to work on minimal Win32 installations and other platforms, which is why it's wrapped in NT DOS batch language.

Oh, nearly forgot, you might need to fix your Perl installation so that it globs file names. See perldoc perlwin32 and implement the Wild.pm module.

One thing it can't do is include it's own offspring, because of the END_UNLIKELY used as a PRINT terminator. That's unlikely to be a requirement, though. Also make sure that the file you redirect the output to somewhere else so that isn't picked up by the script itself!

@rem = '--*-Perl-*-- @echo off perl "%~dpnx0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl @rem '; #!perl #line 8 use strict; print "\@rem = '--*-Perl-*--\n"; print "\@echo off\n"; print "perl \"%~dpnx0\" %1 %2 %3 %4 %5 %6 %7 %8 %9\n"; print "goto end_of_perl\n"; print "\@rem ';\n"; print "#!perl\n"; print "#line 8\n"; my @files=@ARGV; for my $file (@files) { open(INFILE, '<', $file); print "open (STDOUT, '>', \"$file\");\n"; print "print <<'EOT_UNLIKELY';\n"; while (<INFILE>) { die "Found EOT" if /^EOT_UNLIKELY/; print; } print "EOT_UNLIKELY\n"; } print "__END__\n"; print ":end_of_perl\n"; __END__ :endofperl

In reply to Packaging files in a perl script by PhilHibbs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.