# # Declare three arrays and populate two of them. # my @a; my(@x) = (10, 19, 0, 14, 20, 5, 0, 5, 12, 8, 3, 5); my(@y) = (21, 20, 1, 15, 8, 18, 16, 18, 0, 1, 11, 18); # # Set $_ to a string that looks suspiciously like code. # (Use ' instead of q{} to make the string stand out better.) # $_ = 'map{s@a,g@y;s@a,g@x;}@y;'; # # Change the letter s to 'unshift', and g to 'pop' + newline # (Use a more conventional / instead of ; to separate parts of s.) # s/s/unshift/g; s/g/pop\n/g; # $_ now looks like # map{unshift@a,pop # @y;unshift@a,pop # @x;}@y; # # or equivalently # # map { unshift(@a, pop @y); unshift(@a, pop @x) } @y; # # which if executed, would populate @a with alternating elements # of @x and @y (@x and @y would be empty, but that's immaterial). # # @a = qw(10 21 19 20 0 1 14 15 20 8 5 18 0 16 5 18 12 0 8 1 3 11 5 +18) # # Note that with a simple encoding of 1 = a, 2 = b, ..., # (with 0 = space) this is: # # @a = (qw(j u s t), ' ', qw(a n o t h e r) # , ' ' , qw(p e r l) , ' ' , qw(h a c k e r)) # # Execute the map, populating @a eval; # Now set $_ to this literal string # # print join'',(' ','a'..'z')[ # # followed by all the elements of @a, separated by commas, # and a closing square bracket. # The expression argument to join is now an array slice: # just those elements of (' ', 'a', ... 'z') # that are indexed by members of @a. # # (Using more conventional " instead of qs s and ' instead of q; ;.) # $_ = "print join'',(' ','a'..'z')[" . join(',', @a) . '];'; # Create the slice, join the elements and print it. eval;
Better than caffeine! (Almost ;-) Thanks!

In reply to Re: Delimitiations by VSarkiss
in thread Delimitiations by iamcal

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.