[San-Diego-pm] Perl Meeting on Monday, May 9th

Menolly menolly at mib.org
Tue May 10 12:47:36 PDT 2005

On Tue, 10 May 2005, Randal L. Schwartz wrote:

>>>>>> "Menolly" == Menolly  <menolly at mib.org> writes:
> Menolly>   my %taken;
> Menolly>   @taken{map $_->[0], @{$rd2->{'sth'}->fetchall_arrayref()}} = ();
> Menolly>   my @untaken = grep {!exists $taken{$_->[0]}} @{$rd->{'sth'}->fetchall_arrayref()};
> Menolly>   $testDigest = @untaken[rand(@untaken)]->[0];
> I didn't look at the rest, but this last line is illegal syntax.
> It "accidentally" works, but what you're really saying there
> is the same as:
>        $testdigest = $untaken[rand @untaken];
> And you might as well say what you mean. :)
> It will definitely stop working in the future, and is already a
> "warnable" offense, that you would have caught with -w turned on.

Hmm, I thought we _did_ have -w turned on across the board.  But I don't
think your syntax will work; @untaken is an array of arrayrefs; I need
to select a random element from it, dereference that element, and set
$testDigest to the first (and, as it happens, only) element of the
referenced array.  (It's a ref because of DBI; it's a question of where
I place the complexity.)

menolly at mib.org                    http://www.livejournal.com/~nolly/

On that day, many will say to me, "Lord, Lord, did we not prophesy in
your name, and cast out demons in your name, and do many mighty works
in your name?" And then will I declare to them, "I never knew you;
depart from me you evildoers." -- Matt 7:20-23, RSV

More information about the San-Diego-pm mailing list