Hi,
The script below is suppose to erase off, from a file, all blank lines
including newlines, I wrote the regex is as follows : s/^\s*$//;
however after running the script, a last newline remains.
Can someone explain why the regexp can erase off all newlines in the file
except the last newline.
So how do I construct a regex to erase off all the spaces including new
lines. Is this correct and is this the only way [\n\s\t]+
Thanks
########### start of script#############
##### testing.txt look below ############
use strict;
use warnings;
open (MYDATAS , "<testing.txt") || die $!;
my @datas = <MYDATAS>;
close MYDATAS;
foreach (@datas){
s/^\s*$//;
}
open (WRITEDATAS, ">testing.txt") || die $!;
print WRITEDATAS @datas;
close WRITEDATAS;
############### end of script ###################
############ datas in testing.txt consist of tabs, spaces, newlines
etccc.################
123
########### end of testing.txt ###############
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/