crimper1
09-23-02, 15:52
| All, First off, would anybody know why a script gives differernt results when from a cron job then from the command line? (That's one of my problems, maybe it will be corrected if I fix the problem below.) As I'm sure you've all read and fixed a thousand times before, I'm having a 'Use of initialized value at line #" error after running my program (again from the cron, not from the command line). The code around the error is as follows: ----------------- @file_list = qw(file1 file2 file3); foreach $file (@file_list) { $count = `grep "<a string>" $file | wc -l`; if ($count eq " 0 ") { system (echo "no matches in $file" >> another_file); } else { system (echo "$count matches found in $file >> another_file); } } } ------------------- I'm getting the "unitialized value" error on the 3rd line of the above code AFTER the first foreach loop. When I run the script from the command line, it correctly writes "# matches found in file" but from the cron, it incorrectly writes "no matches found". BTW, I'm not using any "use" or "my" statements before/after this block. Any ideas? |