in reply to (tye)Re5: Hash slices ?
in thread Hash slices ?

I am trying to figure out your "clearly aren't meant" statement and I am failing.

Here are a few lines from perldata:

but entire arrays or array slices are denoted by '@', which works much like the word "these" or "those": @days # ($days[0], $days[1],... $days[n]) @days[3,4,5] # same as @days[3..5] @days{'a','c'} # same as ($days{'a'},$days{'c'}) and entire hashes are denoted by '%': %days # (key1, val1, key2, val2 ...)
Here are the lines of code together with how I read them.
# An array is written like @days and can be thought # of as a list of values @days # ($days[0], $days[1],... $days[n]) # Arrays can be sliced, and a slice of a literal list # is the same as taking a slice of something that # returns a list (in this case a range operator) @days[3,4,5] # same as @days[3..5] # Hash lookups can also be sliced, and a slice of a # literal list is the same as taking a literal # list of lookups. @days{'a','c'} # same as ($days{'a'},$days{'c'}) # You write a hash like %days, and you can think of # it as a list of key/value pairs. %days # (key1, val1, key2, val2 ...)
Now please explain why I shouldn't take the .. as being a range operator in list context. That is what it looks like was meant, and that fits perfectly...

Also note that the "can think of" that I inserted has an implicit, "but that isn't quite correct" inserted...

Replies are listed 'Best First'.
Re: Re (tilly) 11: Hash slices ?
by tye (Sage) on Apr 16, 2001 at 10:46 UTC

    Because your copy of perldata is different from mine. Mine has no ".." in the second example. You are looking at an old version.

            - tye (but my friends call me "Tye")
      Now when did they change that? More importantly I would like to know why.

      For the record the version that I pulled from is 5.005_03, and it is merlyn's version as well as you can see if you look at what he quoted Re: Re: Re: Hash slices ?.

      Anyways I also see a brand spanking new section on slices (which is probably why it was pulled) that does not document this case (which should be fixed). As of 5.6.0 (I don't have 5.6.1, so someone should look and send in a patch) it had a typo, an attempt to swap the first and last terms of @folks was messed up when they tried to write it without a slice.

      So it used to be determinable from the documentation with 5.005_03 (which is hardly, given the problems with 5.6.0, a horribly outdated release to be still running) but is now not. In the old version the relevant snippet was what merlyn posted.