This is a nice one. I have several of these listed as test cases that I'd like to catch, even if partially.
Do you have any idea how to spot such issues or even how to recognize this one specifically using PPI or B::Deparse or some other such tool? Gabor On Thu, Mar 5, 2009 at 11:12 PM, Shlomi Fish <[email protected]> wrote: > The following is a simplified version of a program with a bug that bit me > today: > > {{{{{{{{{{{ > #!/usr/bin/perl > > use strict; > use warnings; > > print_filename(); > > my $filename = "hello.txt"; > > sub print_filename > { > print $filename, "\n"; > } > }}}}}}}}}}} > > Can you see what the problem is? See below for the spoiler. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Spoiler: > -------- > > The problem passes compilation. However, $filename, while it is declared in > the scope of print_filename() is not assigned during the call to it, because > the flow of the program did not reach the assignment yet. So it is declared, > and valid, but not assigned yet and still undef(). > > Regards, > > Shlomi Fish _______________________________________________ Perl mailing list [email protected] http://perl.org.il/mailman/listinfo/perl
