Hi all
I've this Perl script to read all files in a directory and if it finds a
file with a certain then rename the file to header, but is doesn't search
the right directory and doesn't even look for the HPAY header.
Ops forgot to include the script.
#!/usr/bin/perl -w
use strict;
my $dir = "/interfaces/tdbank/test/";
opendir DIR, $dir;
my @files = readdir DIR;
my %hash = ('HPAY' => 'file1' ,
'HRET' => 'file2');
for (my $i=0; $i<scalar(@files); $i++) {
open FILE,"$files[$i]" || die "Unable to open file $files[$i] because
$!\n";
my $header = <FILE>;
print "header -->" , $header, "\n";
close FILE;
my $command = "mv $files[$i] $hash{$header}";
print "command -->", $command, "\n";
system $command;
}
And I get the following Errors:
Use of uninitialized value in concatenation (.) or string at ./process_f
iles.sh line 14.
command -->mv ..
Usage: mv [-i | -f] [--] src target
or: mv [-i | -f] [--] src1 ... srcN directory
readline() on closed filehandle FILE at ./process_files.sh line 11.
Use of uninitialized value in print at ./process_files.sh line 12.
header -->
Use of uninitialized value in hash element at ./process_files.sh line 14
.
Use of uninitialized value in concatenation (.) or string at
./process_files.sh line 14.
command -->mv file1
Usage: mv [-i | -f] [--] src target
or: mv [-i | -f] [--] src1 ... srcN directory
readline() on closed filehandle FILE at ./process_files.sh line 11.
Use of uninitialized value in print at ./process_files.sh line 12.
header -->
Use of uninitialized value in hash element at ./process_files.sh line 14
.
Use of uninitialized value in concatenation (.) or string at
./process_files.sh line 14.
command -->mv file2
Usage: mv [-i | -f] [--] src target
or: mv [-i | -f] [--] src1 ... srcN directory
etrprodftp /usr/local/sbin
Any help would be great..
James Parsons.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]