alyssa
04-10-2006, 01:48 PM
I have a file which I need to pass to another script but the values have had their whitespaces removed. I need to add in a white space at the end of each ".". I've written this to add in the white space but it's not doing anything. It takes in the input file and searches the file but it always leaves the "." at the end of each line.
sub searchAndReplace {
print "\nPlease enter the input file:";
$file = <STDIN>;
chomp $file;
print "\nInput file = $file\n";
open (INPUTFILE,$file) || die "Couln't open the file $file!";
while ($line = <INPUTFILE>) {
$line =~ s/\./ /;
}
}
searchAndReplace;
An example file would be
cat.dog.bird rabbit.
litter bug.lady
I want the substituted file to look like
cat dog bird rabbit
litter bug lady
But it is being output like:
cat dog bird rabbit.
litter bug lady
sub searchAndReplace {
print "\nPlease enter the input file:";
$file = <STDIN>;
chomp $file;
print "\nInput file = $file\n";
open (INPUTFILE,$file) || die "Couln't open the file $file!";
while ($line = <INPUTFILE>) {
$line =~ s/\./ /;
}
}
searchAndReplace;
An example file would be
cat.dog.bird rabbit.
litter bug.lady
I want the substituted file to look like
cat dog bird rabbit
litter bug lady
But it is being output like:
cat dog bird rabbit.
litter bug lady