M
MJL
I'm sure this is not the most efficient way to accomplish my goal of
taking a file of text and converting it into a list of individual
words and punctuation symbols. It works, but I am curious about how
to do it differently. Thanks!
#!/usr/bin/perl
open INF, "./testfile1.txt";
while (<INF>)
{
@words = split;
push @list, @words;
}
foreach(@list)
{
/\S+\w+/;
if ($& ne "") {push @list2, "$&\n";}
if ($' ne "") {push @list2, "$'\n";}
}
open OUTF, ">./testfile2.txt";
print OUTF @list2;
close INF;
close OUTF;
taking a file of text and converting it into a list of individual
words and punctuation symbols. It works, but I am curious about how
to do it differently. Thanks!
#!/usr/bin/perl
open INF, "./testfile1.txt";
while (<INF>)
{
@words = split;
push @list, @words;
}
foreach(@list)
{
/\S+\w+/;
if ($& ne "") {push @list2, "$&\n";}
if ($' ne "") {push @list2, "$'\n";}
}
open OUTF, ">./testfile2.txt";
print OUTF @list2;
close INF;
close OUTF;