Hi Monks, long time no see. I've been off in the desert of .NET, but daily perl from the commandline still sustained me.

Long ago I got into the habit of keeping my iteratively-developed Perl scripts as comments in the files that they generate. For example, I hate that the default X11 Compose maps force a specific order for adding accents (letter + accent), whereas I often find myself wanting the opposite (accent + letter). That way I can type either <Multi_Key> <e> <'> or <Multi_Key> <'> <e> to get é. So, now my ~/.XCompose-ordering contains the following comment: (In the file it's on one line, here split for slight readability)

# perl -lanwe ' BEGIN { push @{$o{0+@$_}}, $_ for map [split//], qw/021 0132 0213 0231 + 0312 0321/; } next unless /LATIN.*LETTER...WITH/; next if /<dead/; my @keys = @F[0..(-1+(grep $F[$_] eq ":", 0..$#F)[0])]; $K=join"-",sort @keys; next if $seen{$K}; $seen{$K}++; next if $K eq "<Multi_key>-<U>-<o>"; next if /LETTER \S+ WITH \S+ AND \S+/; print "@keys[@$_] @F[@keys..$#F]" for @{$o{0+@keys}} ' /usr/share/X11/locale/${LANG}/Compose

I was wondering if any monks had clever ways to execute this code to regenerate the file while keeping the code itself as a comment in the file (using perl -x for example). Currently, I've been using the following Zsh snippet:

file=~/.XCompose-ordering line=$(head -n 1 $file) (print -lr $line ; eval ${line[3,-1]}) > $file

But it'd be much cooler to just do perl -x ~/.XCompose-ordering or even ~/.XCompose-ordering.


In reply to Best way to keep script with generated output by benizi

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.