deepagovind
Technical User
Hi,
I am new perl user. I wish to write each word in a text file separated by spaces on to a new line.
e.g: temp.txt:
This is a nice forum
Good learning Perl
Output:
This
is
a
nice
forum
Good
learning
perl
My script:
#!/usr/intel/bin/perl
open LIST, "temp" or die "$!\n";
open (NEW, ">new" or die "$! error trying to overwrite";
@lines = <LIST>;
#$line =~ s/ /\n/g;
close(LIST);
#print "@lines"; # a space is inserted between elements
$" = "\n"; print "@lines\n";
close(NEW);
Your suggestions gratefully appreciated.
Thnak you.
I am new perl user. I wish to write each word in a text file separated by spaces on to a new line.
e.g: temp.txt:
This is a nice forum
Good learning Perl
Output:
This
is
a
nice
forum
Good
learning
perl
My script:
#!/usr/intel/bin/perl
open LIST, "temp" or die "$!\n";
open (NEW, ">new" or die "$! error trying to overwrite";
@lines = <LIST>;
#$line =~ s/ /\n/g;
close(LIST);
#print "@lines"; # a space is inserted between elements
$" = "\n"; print "@lines\n";
close(NEW);
Your suggestions gratefully appreciated.
Thnak you.