undef is a function that sets a variable to undefined as already pointed out by DragonChild. What you are after is defined which tests to see if a variable is defined so the code you want is:
if (! defined $job) {#passes this print "Job file not found! Check directory!\n";exit; }
However there is another subtle thing going on here that you should be aware of. You declare my $file outside a for loop which uses $file as the loop variable. Take particular note that the contents of $file are only valid inside the loop and that $file is an alias to the items in @files that the loop iterates over. This is not causing a problem in the code you show, but is important to remember. Especially because when you change the contents of a loop variable you are actually changing element of the list that the loop variable is currently aliased to. In you code that means that changing the contents of $file inside the loop changes the contents of an element of @files.
In reply to Re: foreach not a global variable?
by GrandFather
in thread foreach not a global variable?
by jriggs420
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |