CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [rovf] iterating through an array using XML::Simple: Edit Log



Laurent_R
Veteran / Moderator

Oct 24, 2012, 4:13 AM


Views: 1033
Re: [rovf] iterating through an array using XML::Simple

I have no idea, but it definitely looks wrong to me, because it does not make sense to dereference an array slice.

However, it seems that the compiler accepts it if the slice has only one element:



Code
DB<3> $array[0]{bar} = "foo" 

DB<4> x @array
0 HASH(0x200d1c10)
'bar' => 'foo'
DB<5> print @array[0]->{bar}
foo


Even more strangely, if I add a second element to the array of hashes and take a real array slice:


Code
  DB<8> $array[1]{bar} = "baz"; 

DB<9> print @array[0..1]->{bar}
baz


So it seems that, in this case, it takes the last element of the array slice.


(This post was edited by Laurent_R on Oct 24, 2012, 8:25 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Oct 24, 2012, 8:25 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives