Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Sorting array, getting modification of read-only value error

by tobyink (Abbot)
on Nov 28, 2012 at 18:51 UTC ( #1006091=note: print w/ replies, xml ) Need Help??


in reply to Sorting array, getting modification of read-only value error

I suspect autovivification.

Minimal example:

use strict; use warnings; my @sorted = sort { $a->[1] <=> $b->[1] } (undef, undef, undef);
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Sorting array, getting modification of read-only value error
Download Code
Re^2: Sorting array, getting modification of read-only value error
by myelinviolin (Novice) on Nov 28, 2012 at 19:40 UTC
    I think I get what you are trying to say, but I can print out the array with no problems, so the whole thing should be defined, correct? So I am not sure how I would go about fixing this.

      You can print out undefined values. (Though if you have warnings enabled, that kind of behaviour will earn you one.)

      I'm not entirely sure how you'd fix it. Some self-contained code which doesn't rely on files from your system that I don't have on my computer might help.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2014-08-28 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls