Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: modification of read-only in hash ++

by flounder99 (Friar)
on Feb 05, 2004 at 16:36 UTC ( [id://326790]=note: print w/replies, xml ) Need Help??


in reply to modification of read-only in hash ++

A few other notes:
my $x=5; BEGIN {$y=sub{my $r=sub{$x++;warn "sub: $x"};$r->()}} $y->(); #sub: 1 at temp.pl line 2. #deref sub that derefs sub, my before BEGIN, using scalars => autoviv BEGIN {$y=sub{my $r=sub{$x++;warn "sub: $x"};$r->()}} my $x=5; $y->(); #sub: 1 at temp.pl line 1. #deref sub that derefs sub, BEGIN before my, using scalars => autoviv my %x=(1=>5); BEGIN {$y=sub{my $r=sub{$x{1}++;warn "sub: $x{1}"};$r->()}} $y->(); #Modification of a read-only value attempted at temp.pl line 2. #deref sub that derefs sub, my before BEGIN, using hash => ERROR BEGIN {$y=sub{my $r=sub{$x{1}++;warn "sub: $x{1}"};$r->()}} my %x=(1=>5); $y->(); #sub: 1 at temp.pl line 1. #deref sub that derefs sub, BEGIN before my, using hash => autoviv my %x=(1=>5); BEGIN {$y=sub{$x{1}++;warn "sub: $x{1}";}} $y->(); #sub: 6 at temp.pl line 2. #deref sub, my before BEGIN, using hash => uses main's my variable BEGIN {$y=sub{$x{1}++;warn "sub: $x{1}";}} my %x=(1=>5); $y->(); #sub: 1 at temp.pl line 1. #deref sub, BEGIN before my, using hash => autoviv my $x=5; BEGIN {$y=sub{$x++;warn "sub: $x"}} $y->(); #sub: 6 at temp.pl line 2. #deref sub, my before BEGIN, using scalar => uses main's my variable BEGIN {$y=sub{$x++;warn "sub: $x"}} my $x=5; $y->(); #sub: 1 at temp.pl line 1. #deref sub, BEGIN before my, using scalar => autoviv
my head hurts! I'm getting in over my head when it comes to understanding when subs should see "my" variables. Could someone explain what results I should expect?

I don't know how to submit a bug report so please feel free to submit one using my test cases.

AS 5.8.2 808 / win2k

--

flounder

Replies are listed 'Best First'.
Re: Re: modification of read-only in hash ++
by ysth (Canon) on Feb 05, 2004 at 17:15 UTC
    Then this is a wonderful time to learn how to submit a bug report! It takes just a few minutes; start by reading perldoc perlbug.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://326790]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found