[lug] Perl question

Carl Wagner carl.wagner at verbalworld.com
Mon Apr 6 15:36:40 MDT 2009


Hi,

I am working on a Perl module that someone else wrote.

I moved a sub from one file to another.  The sub contained a switch 
statement.
I included "use Switch" near the top of the module.

The Perl program would fail with the error:
# cat server.log
Number found where operator expected at Module1.pm line 823, near "case 2"
        (Do you need to predeclare case?)
Number found where operator expected at Module1.pm line 824, near "case 3"
        (Do you need to predeclare case?)
Did not find leading dereferencer, detected at offset 41073syntax error 
at Module1.pm line 822, near ")
    {"
syntax error at Module1.pm line 824, near "case 3"


But if I include "use Switch" within the sub, it works fine.

Any idea why I can't just do a "use Switch" at the top of the module?
(I have "use Strict" near the top).

Thanks,
Carl.



More information about the LUG mailing list