# File: fileDelBlanks.pl # Title: Read a text file and delete spaces. # Here is the file names.txt: # # File with names # # Author: MM # # Mary # John # Evan # Result: #Filewithnames#Author:MMMaryJohnEvan my $filename; my @line; # all file in an array my $file2string; # all file in a string print "Name of the file (names.txt)? "; $filename = ; chop($filename); # read from keyboard unless (open(IN,"$filename")) { # check if the file exists print "No file with such a name!"; exit; } @line = ; # reads all file in an array $file2string = join("",@line); # array becomes one long string, separator is null # print $file2string; $file2string =~ s/\s//g ; # delete all (g) blanks (\s ) s comes from space print $file2string; close IN; exit;