Hi. I am reading through a file:
A -
B -
C -
D -
E -
F - word; word; word;
F - word; word; finalword;
G -
H -
I am trying to grab the contents in both F lines.
At the moment I've got
#!/usr/bin/perl
foreach $line (@data) {
if ($line =~ /^F/) {
$goodline = $line;
$goodline =~ s/F//g; #take away F
$goodline =~ s/^\s+//; # remove leading whitespace
$goodline =~ s/\s+$//; # remove trailing whitespace
$goodline=~s/\s//g; # remove within whitespace
@goodvalues = split(';', $goodline);
foreach (@goodvalues){
$goodterms = "$_\n";
print "$goodterms";
}
}
}
It does the job nicely and prints results to screen.
But, how do I remove the results to a separate file.
It is because they just seem to write over one another and finalword is the result.
Thanks for looking
A -
B -
C -
D -
E -
F - word; word; word;
F - word; word; finalword;
G -
H -
I am trying to grab the contents in both F lines.
At the moment I've got
#!/usr/bin/perl
foreach $line (@data) {
if ($line =~ /^F/) {
$goodline = $line;
$goodline =~ s/F//g; #take away F
$goodline =~ s/^\s+//; # remove leading whitespace
$goodline =~ s/\s+$//; # remove trailing whitespace
$goodline=~s/\s//g; # remove within whitespace
@goodvalues = split(';', $goodline);
foreach (@goodvalues){
$goodterms = "$_\n";
print "$goodterms";
}
}
}
It does the job nicely and prints results to screen.
But, how do I remove the results to a separate file.
It is because they just seem to write over one another and finalword is the result.
Thanks for looking