#!/usr/bin/perl use strict; use warnings; use File::Glob qw{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"; ############################################ my $string; my $entry; 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): "; my $filename = ; chomp $filename; open my $fh, "<", $filename or die "Cannot open $filename.\n"; my $DNA; { local $/=undef; $DNA = <$fh>; } close $fh; chomp $DNA; $DNA=~s/\n/,/g; $DNA=~s/,+$//g; # To remove multiple comma created by empty lines in txt file $DNA=~s/,,+/,/g; # To remove trailing comma created by empty lines in txt file $string .= "{$DNA}"; } # Curly brace for entry1 ends: } until ($entry==2); for (bsd_glob $string) { print"\n"; print "~$_~\n"; print $fh "~$_~\n"; } close $output; exit; #############################################