You mean something like this?
#! perl -slw
use strict;
$|++;
warn 'Start : '.localtime() .$/;
my $data = do{ local $/; <> };
warn 'Read : '.localtime() .$/;
my $lines = $data =~tr[\n][\n];
my $idx = chr(0) x ( 4 * $lines );
my( $i, $p ) = ( 1, 0 );
substr( $idx, 4*$i++, 4 ) = pack 'N', $p
while $p = 1+index $data, $/, $p;
my $n = $lines;
for my $p ( 0 .. $n-1 ) {
my $next = $p + int rand( $n-- );
my $t = substr( $idx, $p*4, 4 );
substr( $idx, $p*4, 4 ) = substr( $idx, $next*4, 4 );
substr( $idx, $next*4, 4 ) = $t;
}
warn 'Shuffled: '.localtime().$/;
printf substr(
$data,
unpack( 'N', substr( $idx, 4*$_, 4 ) ),
index( $data, $/, $_+1 ) - $_ + 1
) for 0 .. $lines;
warn 'Written : '.localtime().$/;
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.