Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Problems with array references and 'use strict'

by hanenkamp (Pilgrim)
on Dec 02, 2003 at 14:35 UTC ( [id://311627]=note: print w/replies, xml ) Need Help??


in reply to Problems with array references and 'use strict'

Your problem is in the line reading:

$vectorRef = { 'time' => \(), 'data' => \() };

Using \() is like trying to take the address of nothing and it appears that Perl does in fact interpret this as nothing. Actually, It almost seems like this should be a warning, but use warnings doesn't complain. Running it in the perl debugger (via the -d switch) shows $vectorRef to contain the following:

0 HASH(0x8162084) 'time' => 'data'

Obviously, this isn't what you meant. The solution is to change each \() to [] which is the anonymous array reference constructor (less line noise too). This would make the code read:

$vectorRef = { 'time' => [], 'data' => [] };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found