[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] Is this necessary? (perl code)
iirc, @{} is an array dereference. Forced array casting is done by enclosing the function call in parenthesis.
$arr_ref = [1,2,3,4];
print $arr_ref->[1]; # grab a single item; prints "2"
@arr_copy = @$foo; # de-reference the whole thing to make a copy
@arr_copy = @{$foo}; # same, but more explicit way
...
@rv_copy = @{$obj -> method()}; # We have to do this to get the order of operations right.
sub method { return [1,2,3,4] }
The same goes for hash %{} and scalar ${} de-referencing.
$scalar = 42;
$scalar_ref = \$scalar; # Perl's scalar references are funny
--
James Harr <jharr@ist.unomaha.edu>
402-554-3340
Assistant Research Systems Manager
College of Information Science and Technology
University of Nebraska at Omaha
From: omaha-pm-bounces+jharr=ist.unomaha.edu@pm.org [mailto:omaha-pm-bounces+jharr=ist.unomaha.edu@pm.org] On Behalf Of Jay Hannah
Sent: Thursday, December 11, 2008 10:11
To: Justin Esbenshade
Cc: omaha-pm@pm.org
Subject: Re: [Omaha.pm] Is this necessary? (perl code)
I think @{ } is redundant with the fact that
my ($response, $success) =
should put forward() into array context anyway.
(Presumably forward() is using wantarray (perldoc -f wantarray) to determine what it should return based on the requested context.)
Try removing @{ } and then test both success ($twig, 1), and failure (0) returns from forward() to see if everything downstream from that code survives... :)
HTH,
j
________________________________________
From: Justin Esbenshade
Sent: Thu 12/11/2008 9:34 AM
my ($response,$success) = @{$c->forward('OWS', 'CreateBooking', [ $room_args ])};
Is the @{ } required around the method call? The few pages I saw from a Google search did not have that.
We're getting a Phoenix Fatal Error that's occurring saying we Can't use string ("0") as an ARRAY ref