N
nj_perl_newbie
I apologize for posting such a basic question...I have spent a
substantial ammount of time reading thick books trying to figure out
how to do this.
The goal is to read the second field in a text file and compare that
string to a list of filenames in a directory.
So use submits a file with "foo, test.txt" the script will look for
"test.txt" in the directory, if it exists it will copy test.txt to a
different directory.
Here's what I have:
opendir(DIR, $limbodir);
&log_entry($logfh,"Opening Limbo Directory"); if $debug;
@files = grep { /\.csv$/ } readdir(DIR);
&log_entry($logfh, "Files in limbodir read") if $debug;
closedir(DIR);
open (FILE, "$cnfrm_file") || die();
($line)= <FILE>; #Read only the first line into the input file.
while (<FILE>) { #not sure if the while is needed
my @line = split /\,/, $_;
my($firstfield, $filename, $junk) = @line;
unless ( $firstline ) {
#attempts to match the filename submitted in the confirm file with
an already existing input file in the limbo directory
if ( $filename) {
( $filename =~ m/^@files/i ) {
&log_entry($logfh, "Confirm submitted by $username for input
file $path/$basename ");
move ("$_", "$transdir/$basename") || die "move failed: $!";
&log_entry($logfh, "$_ moved to $transdir");
chown 23456,23458, "$transdir/$_" || warn $!;
}
Thanks
substantial ammount of time reading thick books trying to figure out
how to do this.
The goal is to read the second field in a text file and compare that
string to a list of filenames in a directory.
So use submits a file with "foo, test.txt" the script will look for
"test.txt" in the directory, if it exists it will copy test.txt to a
different directory.
Here's what I have:
opendir(DIR, $limbodir);
&log_entry($logfh,"Opening Limbo Directory"); if $debug;
@files = grep { /\.csv$/ } readdir(DIR);
&log_entry($logfh, "Files in limbodir read") if $debug;
closedir(DIR);
open (FILE, "$cnfrm_file") || die();
($line)= <FILE>; #Read only the first line into the input file.
while (<FILE>) { #not sure if the while is needed
my @line = split /\,/, $_;
my($firstfield, $filename, $junk) = @line;
unless ( $firstline ) {
#attempts to match the filename submitted in the confirm file with
an already existing input file in the limbo directory
if ( $filename) {
( $filename =~ m/^@files/i ) {
&log_entry($logfh, "Confirm submitted by $username for input
file $path/$basename ");
move ("$_", "$transdir/$basename") || die "move failed: $!";
&log_entry($logfh, "$_ moved to $transdir");
chown 23456,23458, "$transdir/$_" || warn $!;
}
Thanks