#!/usr/bin/perl use strict; use Tie::File; use List::Util qw/shuffle/; my $line; my $i=0; my @array; my $count=0; my $alphaFile = 'alphabetFile.txt'; my $numberFile = 'numberFile.txt'; my $fileCounter = 'counter.txt'; my $tempFile = 'temp.txt'; open(FILECOUNTER,$fileCounter); $count = ; chomp($count); &readfile(); sub readfile { tie @array, 'Tie::File', $numberFile || die("failed to open $numberFile");; my %hashData; open(CHARFILE, $alphaFile) || die("failed to open $alphaFile"); if ($count == 5) { $count=0; unlink($tempFile); } else { $count++; } open(FILECOUNTER,">$fileCounter") || die("failed to open $fileCounter"); print FILECOUNTER $count; close(FILECOUNTER); if (-e $tempFile) { open(TEMPFILE,"+<$tempFile") || die("failed to open $tempFile"); while () { chomp; if ($_) { $_ =~ s/\s+//; $hashData{$_} = 1; } } } else { open(TEMPFILE,">>$tempFile") || die("failed to open $tempFile"); } my $counter=0; tell(TEMPFILE); while ($line = ) { chomp($line); if (exists $hashData{"$line$array[$i]"}) { next; } else { $hashData{"$line$array[$i]"} = 1; #print TEMPFILE "$line $array[$i]\n"; #print "$line $array[$i]\n"; if ("$line $array[$i]") { foreach ( $line ) { if ( $array[$i] ) { print $line . " "; print shuffle $array[$i] . "\n"; print TEMPFILE "$line $array[$i]\n" } else { print "\n" . $line . " " . rand "$array[$i]" . "\n"; print TEMPFILE "$line $array[$i]\n" } } } } $i++; } print TEMPFILE "\n\n"; close(TEMPFILE); close(CHARFILE); untie @array; } #### for example: RUN1 output a 1 b 2 c 3 skipping… l 3 m 1 RUN2 output a 3 b 5 c 1 skipping… l 2 m 4 RUN3 output a 5 b 1 c 4 skipping… l 1 m 5