- SEE ALSO
File::Shuffle - Randomly shuffle the lines in a file.
use File::Temp qw(tempfile); use File::Shuffle qw(fileShuffle); use Data::Dump qw(dump); my ($handle, $inputFile) = tempfile(); print $handle join("\n", 0..9, ''); close $handle; fileShuffle (inputFile => $inputFile); open ($handle, '<', $inputFile); my @lines = <$handle>; close $handle; print @lines;
File::Shuffle provides the routine
fileShuffle to randomly shuffle the lines in a file.
fileShuffle randomly shuffles the lines in a file with the following parameters:
inputFile => '...'
inputFileholds the path to the file whose lines are to be shuffled; if it does not exist or if it is not a file an exception is thrown.
outputFile => '...'
outputFileis the file the shuffled lines are to be written to, it may equal
inputFile; the default is
tempDirectory => File::Temp::tempdir()
tempDirectoryis a temporary directory that intermediate files are written to if the
inputFileis too large to shuffle using only internal memory; the default is set using File::Temp::tempdir().
encoding => ''
encodingis the encoding to used when openning the input and output files; the default is the the system default of the Perl
fileSizeBound => 1000000
If the input file contains less than
fileSizeBoundbytes, the file will be shuffled entirely using internal memory, otherwise Sort::External is used to shuffle the lines in the file.
Use CPAN to install the module and all its prerequisites:
perl -MCPAN -e shell cpan> install File::Shuffle
Please email bugs reports or feature requests to
email@example.com, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Shuffle. The author will be notified and you can be automatically notified of progress on the bug fix or feature request.
Copyright (c) 2009 Jeff Kubina. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
file, permute, randomize, shuffle