Gossamer Forum
Home : General : Perl Programming :

variable masks earlier declaration

Quote Reply
variable masks earlier declaration
Hi,

appreciate if anyone can explain this error message:

"my" variable $sql masks earlier declaration in same scope at C:/Inetpub/wwwroot/cgi-bin/somefile.pl line 45



Quote Reply
Re: [matgos] variable masks earlier declaration In reply to
Hi,

Basically, it means you have already pre-defined a variable. For example:

Code:
my $test = 1;

my $test = 5;

...would give the same error message (because you are defining the same variable more than once Smile)

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] variable masks earlier declaration In reply to
Not define per se, but declare. The variable was redeclared in the same scope. Not an error per se, but a warning. However, very common. I used to do this a fair bit when I originally started to code in 'strict' a number years back.

----
Cheers,

Dan
Principal

Virtual Solutions
Quote Reply
Re: [dan] variable masks earlier declaration In reply to
Hi,

Yup, easily done :) Most of the time, you can get away with it (unless you are "overwriting" something you actually didn't wanna overwrite =))

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] variable masks earlier declaration In reply to
Been mostly coding in PHP lately, but I believe if run with -w switch (e.g., #! /usr/bin/perl -w), warning messages like this will display. Or better, use warnings;

----
Cheers,

Dan
Principal

Virtual Solutions
Quote Reply
Re: [Andy] variable masks earlier declaration In reply to
Thanks.