jriggs420 has asked for the wisdom of the Perl Monks concerning the following question:
I get the use of uninitialized variable in the last line ($job) which doesn't make sense to me because I call it later on in the script, and it is there! Any ideas? TIA#!/usr/bin/perl -w use Cwd; opendir(DIR, "."); @files = readdir(DIR); closedir(DIR); my $file; my $i=0; foreach $file (@files) { if ($file=~ /^(rs|rp|re|tv|pr|do)[0-9]{7}$/){$job=$file; print "$job\n";}#prints $job's value no problem if (undef $job) {print "Job file not found! Check directory!\n +";exit;}#passes this $cwd = cwd(); #my $job=$job;#just trying some stuff-- print $job."\n";#blank print "$cwd\nrand can only be used in a 'projects' folder!\n"; if ($cwd !~ /\/script\/projects\/$job/){exit;}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: foreach not a global variable?
by dragonchild (Archbishop) on Apr 21, 2006 at 20:23 UTC | |
|
Re: foreach not a global variable?
by GrandFather (Saint) on Apr 21, 2006 at 22:46 UTC | |
|
Re: foreach not a global variable?
by jwkrahn (Abbot) on Apr 21, 2006 at 22:18 UTC |