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 16:27
Subject:
Re: This Week on perl5-porters (10-16 March 2003)
Message ID:
20030318011547.952E.H.M.BRAND@hccnet.nl
On Tue 18 Mar 2003 00:27, Abigail <abigail@abigail.nl> wrote:
> On Mon, Mar 17, 2003 at 11:21:18PM +0100, Rafael Garcia-Suarez wrote:
> > 
> >   Hugo asks why the one-liner :
> > 
> >       perl -le 'print $a++'
> > 
> >   prints "0". Abigail doesn't find this behavior strange, and (as
> >   expected) has "written code that depends on this". The discussion
> >   continues.
> > 
> 
> 
> Just to avoid people getting the impression I went out of my way
> to make use of this behaviour, here's a simple example:
> 
>     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;

Not pretending that this is better, just different, evenly short, but not
relying on debatable initial states.

-- 
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