Nov 10, 2013, 2:19 PM
Post #6 of 27
The first thing you should do is to add the following lines near the top of your file:
Re: [zak100] Storing the output of perl command in a file
[In reply to]
This will force you to declare all the variables that you use (with the my operator), but you will save tremendous gains because the compiler will tell you about many of the errors that you are doing.
For example, it will tell you that the $existingdir has not been declared anywhere, so that your test:
... unless -d $existingdir
is just useless.
Then, you write "Bob\n" into the file $filename. Fine.
But the final line of your script
just does not make any sense: you are calling a system command to execute the Perl script $filename, which does not contain a valid Perl script and passing a parameter ($_) which is not defined. This is doomed to fail: Perl will not be able to compile a file containing simply "Bob". I suspect you are trying to do something else, but can't figure out what exactly.
print MYFILE `perl $fileName $_`;
Please explain what you are trying to do with this last command of your script.