develooper Front page | perl.perl5.porters | Postings from March 2003

Re: This Week on perl5-porters (10-16 March 2003)

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
March 17, 2003 22:49
Subject:
Re: This Week on perl5-porters (10-16 March 2003)
Message ID:
20030318074552.4C25.H.M.BRAND@hccnet.nl
On Tue 18 Mar 2003 02:23, Enache Adrian <enache@rdslink.ro> wrote:
> On Tue, Mar 18, 2003 at 01:27:05AM +0100, H.Merijn Brand wrote:
> > > 
> > >     my $i;
> > >     my %months = map {$_ => $i ++} qw /Jan Feb Mar Apr May Jun
> > >                                        Jul Aug Sep Oct Nov Dec/;
> > 
> > Written less ambigous as
> > 
> > my %month;
> > @month(qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)) = 0..11;
> 
> Sorry if slightly off-topic, but don't you think that
> January is the 1st month of the year and December the 12th ? :)
> 
>  my %months = map {$_ => ++$i } qw /Jan Feb Mar Apr May Jun
>                                     Jul Aug Sep Oct Nov Dec/;
> 
>  @month { qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) } = 1..12;

No for two reasons:

0. This is a translation of Abigail's post
1. Read Philips comment

Of course, abigails code can be made unambiguous my just changing

my $i;

to

my $i = 0;

But that was besides the point.

FWIW I never relied on either behaviour discussed in that thread. I tend to
     always initialize my variable when appropriate, even empty hashes and
     arrays;

-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0 & 633 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
  WinNT 4, Win2K pro & WinCE 2.11.  Smoking perl CORE: smokers@perl.org
http://archives.develooper.com/daily-build@perl.org/   perl-qa@perl.org
send smoke reports to: smokers-reports@perl.org, QA: http://qa.perl.org



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About