Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Modification of non-creatable array value attempted, subscript -1 error

by Anonymous Monk
on Feb 21, 2014 at 00:58 UTC ( [id://1075669]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Modification of non-creatable array value attempted, subscript -1 error
in thread Modification of non-creatable array value attempted, subscript -1 error

If the array is empty, then -1 goes to -1 which cannot exist

If the array is not empty, then -1 goes to the last element (it exists)

$ perl -Mdiagnostics -e " my @f; $f[-1] = 0; " Modification of non-creatable array value attempted, subscript -1 at - +e line 1 (#1) (F) You tried to make an array value spring into existence, and th +e subscript was probably negative, even counting from end of the arr +ay backwards. Uncaught exception from user code: Modification of non-creatable array value attempted, subscript + -1 at -e line 1. $ perl -Mdiagnostics -e " my @f = 0; $f[-1] = 0; "
  • Comment on Re^3: Modification of non-creatable array value attempted, subscript -1 error
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found