I have here a little thing called swap_row_col.pl. It's very old (my filesystem says I haven't touched it in more than 4 years) so I just refactored it now. Once swapped in this way, the data can be List::Util::shuffle'd and swap_row_col'ed again. This is tested:

use warnings; use strict; use List::Util qw/shuffle/; sub swap_row_col { my @swapped; foreach (@_) { chomp; ## just in case my @elems = split /;/; for (my $i = 0; $i < @elems; $i++) { exists $swapped[$i] and $swapped[$i] .= ';'; $swapped[$i] .= $elems[$i]; } } return @swapped; } my @vshuffled = swap_row_col shuffle swap_row_col <DATA>; __DATA__ one;two;three;four foo;bar;baz;qux yellow;red;blue;green

The output from Data::Dumper is something like this:

$VAR1 = [ 'one;three;four;two', 'foo;baz;qux;bar', 'yellow;blue;green;red' ];

--
David Serrano


In reply to Re: A vertical (+/- random) split of a file by Hue-Bond
in thread A vertical (+/- random) split of a file by Marsel

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.