in reply to Re: Mixing Up a Text File
in thread Mixing Up a Text File
NB: the $i++ and regex trickery is necessary to preserve identical lines.#!/usr/bin/perl -w use strict; my(%hash,$i); @hash{map($i++.":$_", <>)} = (); print "$_\n" for map /^\d+:(.*)/, keys %hash;
Which I guess was not the point, since we're back to using rand()#!/usr/bin/perl -w use strict; my(%hash,$i); @hash{map join(":", $i++, int rand $i, $_), <>} = (); print "$_\n" for map /^\d+:\d+:(.*)/, keys %hash;
|
|---|