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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |