C
Chris L.
Dear Experienced Perl programmmer:
I am having trouble understanding exactly why I can print the below
program just fine through my IDE console, but when I try printing the
exact same array (@goose) to a text file through a file handle, it only
prints the last entry...
Again, I have pasted my code below, and would appreciate any advice as
to how to remedy this problem. I have gone over all three of my Perl
books and searched Google for the last 4 hours, and cannot find the
answer...
Thank you very much for your help
Chris
-------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
open(ORIGINN, "C:\\Documents and Settings\\Admin\\My
Documents\\ci_p.txt")|| die "Cannot open bci_pep.txt: $!";
#opening my text file
my (@DATA)=<ORIGINN>;
close (ORIGINN);
#copied my text file to array @DATA
my@UUOO = grep /Entry/, @DATA;
#grabbed each line in my array starting with Entry
foreach my$cone (@UUOO){
my $var= substr($cone, 28, -1);
#selected a particular word from each line in UUOO array
my @goose="$var\n" ;
print @goose;
#prints out in the Active State Komodo IDE output screen PERFECTLY!
open(LOGF, ">C:/entry.txt")|| die "Cannot open entry.txt: $!";
print LOGF @goose;
close(LOGF);
#prints only the last entry to the text file "entry.txt
Howcome??
}
I am having trouble understanding exactly why I can print the below
program just fine through my IDE console, but when I try printing the
exact same array (@goose) to a text file through a file handle, it only
prints the last entry...
Again, I have pasted my code below, and would appreciate any advice as
to how to remedy this problem. I have gone over all three of my Perl
books and searched Google for the last 4 hours, and cannot find the
answer...
Thank you very much for your help
Chris
-------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
open(ORIGINN, "C:\\Documents and Settings\\Admin\\My
Documents\\ci_p.txt")|| die "Cannot open bci_pep.txt: $!";
#opening my text file
my (@DATA)=<ORIGINN>;
close (ORIGINN);
#copied my text file to array @DATA
my@UUOO = grep /Entry/, @DATA;
#grabbed each line in my array starting with Entry
foreach my$cone (@UUOO){
my $var= substr($cone, 28, -1);
#selected a particular word from each line in UUOO array
my @goose="$var\n" ;
print @goose;
#prints out in the Active State Komodo IDE output screen PERFECTLY!
open(LOGF, ">C:/entry.txt")|| die "Cannot open entry.txt: $!";
print LOGF @goose;
close(LOGF);
#prints only the last entry to the text file "entry.txt
Howcome??
}