On Dec 10, 2007 2:31 PM, <[EMAIL PROTECTED]> wrote: snip > But I did stick an undef in at if (!$OutputFile) so > if (undef $OutputFile) > > Then the warning moved on to line 66 where the code attempts to use > OutputFile. Seems to indicate OutputFile was gettiong a varlue in the > if clause. snip
That does not do what you think it does. The undef function makes its argument variable undefined. You are looking for the defined function like this if (not defined $OutputFile) { or this unless (defined $OutputFile) { depending on your tastes. Also, there are better ways to write that code: my $OutputFile = shift || "/home/reader/projects/perl/work/myfile"; die "<$OutputFile> cannot be found .. exiting\n" unless -f $OutputFile; The shift function defaults to @ARGV when called in the body of program (it defaults to @_ in subroutines) and the or operator returns the first true item (if any), so the construct shift || "default" will return the value from @ARGV if it is set (and non-zero) or the default value. The die function prints its argument to STDERR (with the file and line number if it does not end with \n) and exits the program with a non-zero error code. The new // operator that will be available in Perl 5.10 returns the first defined item (if any). This makes it a much better choice for defaulting logic like this. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/