#!/usr/bin/perl #1 add use strict use strict; use warnings; #2 add '' use File::Glob('bsd_glob'); ############################################ ## Output to a TEXT File using file handle: ############################################ my $output="Joint.txt"; open (my $fh,">",$output) or die"Cannot open file '$output'.\n"; #3 declare variables my (@array,@DNA,@list); my ($filename,$combi,$entry,$number,$DNA); do { print"\n\n Press 1 to Enter New File or 2 to Combine: "; $entry=; chomp $entry; if ($entry==1) { print"\n\n Enter New File Name (.txt): "; $filename = ; chomp $filename; unless ( open(FILE, $filename) ) { print "Cannot open file \"$filename\"\n\n"; exit; } @DNA= ; close FILE; #5 add chomp chomp(@DNA); #6 add join by comma $DNA = join(',',@DNA); push @array, $DNA; #7 not needed array1=array; } elsif ($entry==2) { # Curly brace for entry2 starts $number=@array; print"\n\n No. of Elements in Joined Array: $number\n"; print $fh "\n\n No. of Elements in Joined Array: $number\n"; # To produce all possible combinations of different elements: #10 use simple $_ on @array $combi = join('',map {'{'.$_.'}'} @array); @list = bsd_glob($combi); print"\n Results:\n"; print $fh "\n Results:\n"; #11 print each element on new line print join "\n",@list; print $fh join "\n",@list; } # Curly brace for Entry 2 ends: } until ($entry==2); # Square bracket for do-until: close $output; exit;