Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Printing from three arrays

by AnomalousMonk (Archbishop)
on Sep 26, 2019 at 18:20 UTC ( [id://11106758]=note: print w/replies, xml ) Need Help??


in reply to Re: Printing from three arrays
in thread Printing from three arrays

IIRC, glob iterates most slowly over its first (leftmost) iteration group,  {1,2,3} in this case, and more rapidly over each succeeding iteration group, so that the the last (rightmost) group  {I,II,III} iterates most quickly. This is the behavior I see in the output of your example code: the first (leftmost, arabic-number) field or column of each  "1aI" output record/string changes most slowly, the second (middle, alpha) changes more quickly, and the third (rightmost, roman-number) column changes fastest.

However, oysterperl, as shown in the example of desired output in the OP, seems to want the first (leftmost, arabic-number) column to change most quickly, the second (alpha) column to change most slowly, and the third (roman-number) column to change at an intermediate rate. Is it possible to produce this result with a glob solution? (The OPed example output also has commas separating the columns, but this is easily done with a glob template.)


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: Printing from three arrays
by FreeBeerReekingMonk (Deacon) on Sep 26, 2019 at 22:09 UTC
    I checked the glob page, and I could not find something that would make it change it's ways, so you would need to split and join it :(

    perl -e '@_=split(/=/, $_) and print join(", " ,@_[2,0,1]),"\n" for glob "{a,b,c}={I,II,III}={1,2,3,4}"'

    it's cumbersome, though. I tried something with unshift pop but it was longer.

    perl -E '@_=split /=/ and unshift(@_,pop @_) and say join ", ", @_ for glob "{a,b,c}={I,II,III}={1,2,3,4}"'

    perl -E '@_=split /=/ and say join ", ", unshift(@_, pop @_) && @_ for glob "{a,b,c}={I,II,III}={1,2,3,4}"'

      Not really much (if any) better:

      c:\@Work\Perl\monks>perl -wMstrict -le "use 5.014; ;; print s{\A(.+?),(.+?),(.+?)}{$3,$1,$2}xmsr for glob '{a,b,c},{I,II,III},{1,2,3,4}'; "
      (I won't show the output; it's as expected.)


      Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11106758]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found