[Milan-pm] PErl Test

Hakim Cassimally hakim.cassimally at gmail.com
Tue Mar 24 10:16:54 PDT 2009


2009/3/24 marcos rebelo <oleber at gmail.com>

> refresh
>

Ah!  Apologies, I did think to refresh, but apparently I can't drive
Firefox...
Thanks ;-)

osf'


>
> 2009/3/24 Hakim Cassimally <hakim.cassimally at gmail.com>:
> > 2009/3/24 marcos rebelo <oleber at gmail.com>
> >>
> >> it is correct now
> >
> > Correct how?
> >
> > use strict; use warnings;
> > use Data::Dumper;
> > use Test::More tests => 1;
> >
> > my %a;
> > @a{1,2,19,6,2,6}=(1..6);
> > my $keys = [ keys %a ];
> >
> > is_deeply
> >     $keys,
> >     [ 1, 19, 2, 6 ],
> >     'http://milan.pm.org/perl_test.html, question 14'
> >     or diag Dumper $keys;
> >
> > ####
> > 1..1
> > not ok 1 - http://milan.pm.org/perl_test.html, question 14
> > #   Failed test 'http://milan.pm.org/perl_test.html, question 14'
> > #   at isd.pl line 11.
> > #     Structures begin differing at:
> > #          $got->[0] = '6'
> > #     $expected->[0] = '1'
> > # $VAR1 = [
> > #           '6',
> > #           '1',
> > #           '19',
> > #           '2'
> > #         ];
> > # Looks like you failed 1 test of 1
> >
> > osf' ;-)
> >
> >>
> >> 2009/3/24 Hakim Cassimally <hakim.cassimally at gmail.com>:
> >> > 2009/3/24 marcos rebelo <oleber at gmail.com>
> >> >>
> >> >> On Tue, Mar 24, 2009 at 5:54 PM, Michele Beltrame <
> mb at cattlegrid.info>
> >> >> wrote:
> >> >> > I would say number 14 could be changed a bit, as keys() might
> return
> >> >> > keys in any order, so arrays shown as options could not be correct
> as
> >> >> > far as ordering is concerned.
> >> >>
> >> >> before there was a sort in there. You don't imagine the casino in the
> >> >> Lisbon PM, the alphabetic order, ...
> >> >>
> >> >> So at the end, this is the only possible answer.
> >> >
> >> > Except that without the sort the answer is wrong, and with the sort
> the
> >> > answer is right ;-)
> >> >
> >> > DB<6> @a{1,2,19,6,2,6}=(1..6); print Dumper([ sort keys %a
> >> > ]);
> >> > $VAR1 = ['1','19','2','6'];
> >> >
> >> > You could try sort { $a <=> $b } keys %a to be clearer?
> >> > osf'
> >
> >
> > _______________________________________________
> > Milan-pm mailing list
> > Milan-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/milan-pm
> >
> >
>
>
>
> --
> Marcos Rebelo
> http://oleber.freehostia.com
> Milan Perl Mongers leader http://milan.pm.org
> _______________________________________________
> Milan-pm mailing list
> Milan-pm at pm.org
> http://mail.pm.org/mailman/listinfo/milan-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/milan-pm/attachments/20090324/32859798/attachment.html>


More information about the Milan-pm mailing list