R
RodFGWA
I need help with file manipulation in Perl.
I want to open a text file that contains the names and locations of
about 650 text files that I need to evaluate.
C:\DIRA\SUBDIRA\FILENAMEZZ.txt
C:\DIRB\SUBDIRX\FILENAMEYY.txt
I want to open each file in the text file and print the first ten lines
in the file to an OUTPUT FILE ( BY APPENDING ).
I then want to print a distinct seperator, like "*****".
This doesn't have to run very fast.
I know the code below only prints the string from the file, but I was
just testing the beginning code.
I have the following code so far:
# Define the source file for evaluation
$input_file = 'SR20051004.txt';
# Open the file
open(INPUT_FILE, $input_file);
# NOTE:
#
# HERE I WANT TO OPEN A FILE FOR APPENDING
#
#
# Read it into an array
@lines = <INPUT_FILE>;
# Close the File
close(INPUT_FILE);
foreach $line (@lines)
{
# HERE IS WHERE I NEED HELP
#
# I WANT TO OPEN EACH FILE $line
#
# I WANT TO OUTPUT THE FIRST TEN LINES TO THE OUTPUT FILE
#
# I WANT TO PRINT MY SEPERATOR TO THE FILE
#
# I WANT TO CLOSE EACH FILE
print "$line";
}
Your help would benefit me greatly as I am completely an amatuer wit
Perl but know that ir is great with this sort of activity.
I am having trouble finding any information on opening files from the
data contained in variables.
I want to open a text file that contains the names and locations of
about 650 text files that I need to evaluate.
C:\DIRA\SUBDIRA\FILENAMEZZ.txt
C:\DIRB\SUBDIRX\FILENAMEYY.txt
I want to open each file in the text file and print the first ten lines
in the file to an OUTPUT FILE ( BY APPENDING ).
I then want to print a distinct seperator, like "*****".
This doesn't have to run very fast.
I know the code below only prints the string from the file, but I was
just testing the beginning code.
I have the following code so far:
# Define the source file for evaluation
$input_file = 'SR20051004.txt';
# Open the file
open(INPUT_FILE, $input_file);
# NOTE:
#
# HERE I WANT TO OPEN A FILE FOR APPENDING
#
#
# Read it into an array
@lines = <INPUT_FILE>;
# Close the File
close(INPUT_FILE);
foreach $line (@lines)
{
# HERE IS WHERE I NEED HELP
#
# I WANT TO OPEN EACH FILE $line
#
# I WANT TO OUTPUT THE FIRST TEN LINES TO THE OUTPUT FILE
#
# I WANT TO PRINT MY SEPERATOR TO THE FILE
#
# I WANT TO CLOSE EACH FILE
print "$line";
}
Your help would benefit me greatly as I am completely an amatuer wit
Perl but know that ir is great with this sort of activity.
I am having trouble finding any information on opening files from the
data contained in variables.