[Pdx-pm] accessing list elements

Michael Rasmussen mikeraz at patch.com
Wed Sep 3 17:45:47 CDT 2003


When reading through some code I came across this:

my $pic = $files[rand @files];

huh?  rand returns a "random fractional number". And lists are
accessed through integers.  

Or not?

A simple test case shows that you can access list members with
fractional numbers.  This is handy, but puzzling behavior.
I couldn't find a reference to this in the docs.

Is there any explanation to this besides "Perl does what you expect"?

-- 
      Michael Rasmussen  aka  mikeraz
    Be appropriate && Follow your curiosity
 http://www.patch.com/ http://wiki.patch.com/
 http://wiki.patch.com/index.php/BicycleCommuting

   The fortune cookie says:
Being popular is important.  Otherwise people might not like you.



More information about the Pdx-pm-list mailing list