[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Re: help



Actually, if it weren't running with use strict; and -w, this probably
wouldn't stop things.

However, the error is really easy to fix.

Note that the first line declares
> my $inc = '1.00';
and then in the next line you have
> my(..., $inc, ...);

The second mention of $inc in a my clause is re-scoping the variable, and
as you aren't in a different block, Perl wants you to know this.  As it
is now, you would basically have a value of zero for $inc after the
latter declaration (at least, I think that's how it works).

To solve the problem, just don't redefine $inc.  You could either move
the large 'my' statement first, and then leave off the 'my' in front of
$inc = '1.00', or you can just remove the reference to $inc in the latter
statement...

HTH,
Ricky

Amitava Basu <incas@vsnl.net> wrote:

>Hello everyone:
>
>Before I post this question let me wish everyone in
>the list Merry Christmas And A Very Happy And
>Prosperous New Year!!
>
>I am trying to resolve this problem for a long time.
>I have failed and I have to seek your help.
>
>When I run the following subroutine the syntax looks
>okay.  It gives diagnostic error that:
>
>############################################################
>
># "my" variable $inc masks earlier declaration in same
>scope.
>File 'Untitled'; Line 4
>############################################################
>
>the subroutine follows:
>
># Sub: Add New Item
># This allows a new item to be put up for sale
>
>sub new {
> my $inc = '1.00'; # default increment{
> my($title, $reserve, $inc, $desc, $image, @bids);

-----
Pukku
Nothing I say necessarily represents my, or anyone else's, opinions.
I reserve the right to change my mind even in mid-thought.
All spelling errors are copyright by the author, and are intentional

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org