Well I guess I was just not sure of the syntax @{} being able to dereference something like a $sth->selectall_arrayref({}) in DBI.pm. But now i've saved several unnecessary steps by learning that.<br><br><div><span class="gmail_quote">
On 12/7/05, <b class="gmail_sendername">Michael J. Freeman</b> <<a href="mailto:mfreeman@netcogov.com">mfreeman@netcogov.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Why do you want to copy that hash to $b though? Why not just dereference $a? I<br>use to do this myself a lot before I got the hang of referencing and then got<br>bitten by it.<br><br>On Wednesday 07 December 2005 08:14, Eric Estabrooks wrote:
<br>> Ken Williams wrote:<br>> >Double correction, it should have been:<br>> ><br>> > $a = {b => [1,2,3]}<br>> ><br>> >The solution you're looking for is:<br>> ><br>> > @result = @{ $b->{b} };
<br>><br>> I hate to disagree but you need to do a double dereference on $b since<br>> its a ref to a scalar that holds a ref to a hash. If you want to just<br>> have a single dereference then it would be a sort of combination of the
<br>> two corrections.<br>><br>> %a = (b => [1,2,3]);<br>> $b = \%a;<br>> @c = @{ $b->{b} };<br>> $val = $b->{b}[1];<br>><br>> Eric<br>><br>> >The rule is that following the '@' character must either be the name of
<br>> >an array (such as "result" above, or a simple scalar such as $x (e.g.<br>> >@$x) that holds an array reference, or brackets that evaluate to a name<br>> >or an array reference.<br>> >
<br>> >If you're running under "strict" mode, no evaluation is allowed in the<br>> >latter "name" case, it must be a literal name (e.g. @{ result }).<br>> ><br>> >The following code demonstrates a few ways of accessing the same array:
<br>> ><br>> > @x = (1..10);<br>> > print @x; # Literal<br>> > $y = \@x;<br>> > print @$y; # Hard reference<br>> > print @{\@x}; # Hard reference<br>> > print @{"x"}; # Soft reference
<br>> > print @{lc("X")}; # Soft reference<br>> ><br>> >Of course, if you want to address individual elements of your $b->{b}<br>> >structure, you can just use $b->{b}[0], $b->{b}[1], etc.
<br>> ><br>> > -Ken<br>> ><br>> >On Dec 6, 2005, at 9:41 PM, Dave Dash wrote:<br>> >>Actually correction that should be<br>> >><br>> >>%a = {b => [1,2,3]}<br>> >>
<br>> >>On 12/6/05, Dave Dash <<a href="mailto:dd@davedash.com">dd@davedash.com</a>> wrote:Let's say I have a hash:<br>> >>>$a = {b=>(1,2,3)}<br>> >>><br>> >>>and<br>> >>>
<br>> >>>$b = \$a;<br>> >>><br>> >>> Is there a way given $b->{b} to dereference that into the array that<br>> >>>is (1,2,3) ?<br>> >>><br>> >>>Currently I end up doing a lot of annoying steps, but it'd be nice if
<br>> >>>something like @($b->{b}) would work...<br>> >>><br>> >>>--<br>> >>>Dave Dash<br>> >>>612.670.0621<br>> >>>3555 Fremont Ave S, Mpls, MN 55408
<br>> >>><a href="http://citybikemap.com/">http://citybikemap.com/</a><br>> >>><a href="http://davedash.com/">http://davedash.com/</a><br>> >>>AIM: davesdash<br>> >><br>> >>--
<br>> >>Dave Dash<br>> >>612.670.0621<br>> >>3555 Fremont Ave S, Mpls, MN 55408<br>> >><a href="http://citybikemap.com/">http://citybikemap.com/</a><br>> >> <a href="http://davedash.com/">
http://davedash.com/</a><br>> >>AIM: davesdash_______________________________________________<br>> >>Mpls-pm mailing list<br>> >><a href="mailto:Mpls-pm@pm.org">Mpls-pm@pm.org</a><br>> >>
<a href="http://mail.pm.org/mailman/listinfo/mpls-pm">http://mail.pm.org/mailman/listinfo/mpls-pm</a><br>> ><br>> >_______________________________________________<br>> >Mpls-pm mailing list<br>> ><a href="mailto:Mpls-pm@pm.org">
Mpls-pm@pm.org</a><br>> ><a href="http://mail.pm.org/mailman/listinfo/mpls-pm">http://mail.pm.org/mailman/listinfo/mpls-pm</a><br><br>--<br>Michael J. Freeman<br>NMS Development<br>Netco Government Services, Inc.<br>
--<br>The world is full of willing people, some willing to work, the rest willing to<br>let them.<br> -- Robert Frost<br><br><br><br>_______________________________________________<br>Mpls-pm mailing list<br><a href="mailto:Mpls-pm@pm.org">
Mpls-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/mpls-pm">http://mail.pm.org/mailman/listinfo/mpls-pm</a><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>Dave Dash<br>612.670.0621<br>3555 Fremont Ave S, Mpls, MN 55408
<br><a href="http://citybikemap.com/">http://citybikemap.com/</a><br><a href="http://davedash.com/">http://davedash.com/</a><br>AIM: davesdash