main::(-:3): print $message; DB<1> Hmm. Something’s wrong here. The debugger halted at the first executable line of code. (A use statement is a compile time directive, so we don’t expect to see that in the debugger.) Why aren’t we seeing the assignment to $message? No wonder when we examine $message there’s nothing there: DB<1> x $message 0 undef For some reason, line 2 isn’t considered executable. It isn’t commented out, so it must be being executed at compile time instead. Hmm again. That rings a bell. Wait a minute, it comes right after a use statement. Could it be that Perl is considering it to be part of the use statement? At this point, we discover the missing semicolon and probably are too relieved to care about why it happened. But for the curious among you, here’s an explanation: the absence of the semicolon and the fact that all white space (including newlines) looks the same to Perl means that lines 1 and 2 parse as use strict my $message = “Hello Worldn”; If we look at the specification for the use statement, we see that it is use Module LIST So the name of the module can be followed by a list and an assignment is a valid member of a list! Because evaluation occurs in the scope of the use statement, my $message= “Hello Perl Worldn”; ends up scoped inside the implicit BEGIN block created by use, and hence disappears by the next line because it was a lexical variable. The debugger demonstration shows the long way to find our typo, but in this case a shorter error analysis method exists. The -wflag produces warnings for the more common Perl programming problems. Run the program with the -w flag and Perl returns Name “main::message” used only once: possible typo at typo.pl line 3. Use of uninitialized value at typo.pl line 3. As we now know, the assignment of $messagehappens in the wrong place due to the typo. The warning alerts us to the fact that when $messageis used, it doesn’t yet contain a defined value. This example should trouble you. If you put usestrictin all your programs (and if you aren’t doing so already, you will by the time you finish this book), you should be wondering now whether the strictness is in effect. To check, remove my from the $messageassignment. If strictness is in effect, Perl will complain that $message lacks an explicit package name.
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check Actions servlet hosting services