chris01010 has asked for the wisdom of the Perl Monks concerning the following question:
I have written a PERL script to read files from directory that the filename contains OT. It then takes each line of each file and prints the first 5 characters before the first occurence of a /.
Currently I am getting the error:
Use of uninitialized value in string at rowGrab.pl line 43.
Use of uninitialized value in pattern match (m//) at rowGrab.pl line 41.
Can anyone provide some guidance?#!/usr/bin/perl use strict; my $log_dir = '/home/user1'; my $trans_dir = '/data/directoy1'; my $file; my $participant; my @files; my $line; if (!open(LOG, " >>$log_dir/trans.log")) { syslog("Warning:","Cannot open log file called: $log_dir/trans.log" +); die "Cannot open the file $log_dir/trans.log, $!"; } undef (@files); opendir(DIR,$trans_dir); my @files = grep { /(OT)/ # Filename contains OT && -f "$trans_dir/$_" # and is a file } readdir(DIR); foreach $file (@files) { print STDERR "File: $file\n"; open(FILE,"<$trans_dir/$file") or die "Cannot open $file"; print "$file\n"; for $line (<FILE>) { ($participant) =~/(.....)\//; print "$participant"; close (FILE); } } closedir(DIR);
Also prior to putting in string matching, I just printed the filename. This however got the error "Out of memory".
The directory contains 5487 files and each file averages 119 MB.
I understand this is a genuine memory issue, I was just wondering if anyone knew a way round it?
Thanks Chris
|
|---|