G
Graeme Stewart
All,
I've done some lurking and found the answers to most of my questions,
but this one is more of a "best practice" issue, I've not been able to
find an answer for - my apologies if this is blantantly obvious and
I'm a looser newbie for even asking!
I've got a perl script that repeatedly opens and closes a couple of
files then excutes a while loop against those open files (example
below). Rather than repeatedly open and close the files, can I do this
in a better / more efficient way?
The objective is to take a jumbled text file and create individual
lines (records) that I can later manipulate.
*******************************************************
#!C:\perl\bin\perl.exe # Yes Windows! Don't hate me!
use strict;
open FILE, "./QM1.txt" or die "Can not open QM1.txt $!\n";
open COMMENTS, ">./temp/comments.txt" or die "Can not create
comments.txt $!\n";
while (<FILE>){
etc
etc
}
close FILE;
close COMMENTS;
open COMMENTS, "./temp/comments.txt" or die "Can not create
comments.txt $!\n";
open TEMPFILE, ">./temp/temp.txt" or die "Can not create temp.txt
$!\n";
while (<COMMENTS>){
etc
etc
}
close TEMPFILE;
close COMMENTS;
open COMMENTS, ">./temp/comments.txt" or die "Can not create
comments.txt $!\n";
open TEMPFILE, "./temp/temp.txt" or die "Can not create temp.txt
$!\n";
while (<TEMPFILE>){
etc
etc
}
close TEMPFILE;
close COMMENTS;
open COMMENTS, "./temp/comments.txt" or die "Can not create
comments.txt $!\n";
open TEMPFILE, ">./temp/temp.txt" or die "Can not create temp.txt
$!\n";
while (<COMMENTS>){
etc
etc
}
close TEMPFILE;
close COMMENTS;
*******************************************************
I've done some lurking and found the answers to most of my questions,
but this one is more of a "best practice" issue, I've not been able to
find an answer for - my apologies if this is blantantly obvious and
I'm a looser newbie for even asking!
I've got a perl script that repeatedly opens and closes a couple of
files then excutes a while loop against those open files (example
below). Rather than repeatedly open and close the files, can I do this
in a better / more efficient way?
The objective is to take a jumbled text file and create individual
lines (records) that I can later manipulate.
*******************************************************
#!C:\perl\bin\perl.exe # Yes Windows! Don't hate me!
use strict;
open FILE, "./QM1.txt" or die "Can not open QM1.txt $!\n";
open COMMENTS, ">./temp/comments.txt" or die "Can not create
comments.txt $!\n";
while (<FILE>){
etc
etc
}
close FILE;
close COMMENTS;
open COMMENTS, "./temp/comments.txt" or die "Can not create
comments.txt $!\n";
open TEMPFILE, ">./temp/temp.txt" or die "Can not create temp.txt
$!\n";
while (<COMMENTS>){
etc
etc
}
close TEMPFILE;
close COMMENTS;
open COMMENTS, ">./temp/comments.txt" or die "Can not create
comments.txt $!\n";
open TEMPFILE, "./temp/temp.txt" or die "Can not create temp.txt
$!\n";
while (<TEMPFILE>){
etc
etc
}
close TEMPFILE;
close COMMENTS;
open COMMENTS, "./temp/comments.txt" or die "Can not create
comments.txt $!\n";
open TEMPFILE, ">./temp/temp.txt" or die "Can not create temp.txt
$!\n";
while (<COMMENTS>){
etc
etc
}
close TEMPFILE;
close COMMENTS;
*******************************************************