Here are 11 changes/simplifications to make your script work
#!/usr/bin/perl
#1 add use strict
use strict;
use warnings;
#2 add ''
use File::Glob('bsd_glob');
#3 declare variables
my (@array,@DNA,@list);
my ($filename,$combi,$entry,$number,$DNA);
do {
#4 not needed @array=@array1;
print"\n\n Press 1 to Enter New File or 2 to Combine: ";
$entry=<STDIN>;
chomp $entry;
if ($entry==1) {
print"\n\n Enter New File Name (.txt): ";
$filename = <STDIN>;
chomp $filename;
unless ( open(FILE, $filename) ) {
print "Cannot open file \"$filename\"\n\n";
exit;
}
@DNA= <FILE>;
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) {
#8 @array1 not needed use @array
#@array1=@array; # Curly brace for entry2 starts
$number=@array;
print"\n\n No. of Elements in Joined Array: $number\n";
print"\n Joined Array:\n";
print "@array\n";
#9 none of this code required because comma added a #6
# Use of foreach LOOP to view each element of joined array:
#num=0;
#foreach my $element (@array1) {
# $num++;
# print"\n Array No.$num of the Joined Array:\n";
# print $element;
# print"\n";
# Code to surround each element of joined array
# followd by comma i.e. [ ],
# @element=split('',$element);
# $str1 = sprintf '[%s],'x @element,@element;
# print"\n str1: $s\n";
#push @ARRAY1,$element;
#} # Curly brace for foreach ends:
#print"\n ARRAY:\n";
#print @ARRAY1;
#print"\n";
# To produce all possible combinations of different elements:
#10 use simple $_ on @array
#$combi = join('',map {'{'.join (',',@$_).'}'} @ARRAY1);
$combi = join('',map {'{'.$_.'}'} @array);
print "combi = $combi\n";
@list = bsd_glob($combi);
print"\n Results:\n";
#11 print each element on new line
print join "\n",@list;
} # Curly brace for Entry 2 ends:
} until ($entry==2); # Square bracket for do-until:
exit;
poj |