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;}
In reply to foreach not a global variable? by jriggs420
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |