in reply to multiple variable initialization in one line

A couple of ways:
my ($JAN,$FEB,$MAR,$APR,$MAY,$JUN,$JUL,$AUG,$SEP,$OCT,$NOV,$DEC)=0 x 12;
or
my $JAN=$FEB=$MAR=$APR=$MAY=$JUN=$JUL=$AUG=$SEP=$OCT=$NOV=$DEC=0;
Cheers

Update:
as jmcnamara points out, in the first example the 0 should be in parens as in:

my ($JAN,$FEB,$MAR,$APR,$MAY,$JUN,$JUL,$AUG,$SEP,$OCT,$NOV,$DEC)= (0) + x 12;

Sweetblood

Replies are listed 'Best First'.
Re^2: multiple variable initialization in one line
by Random_Walk (Prior) on Jan 31, 2005 at 14:43 UTC

    The second example is not equivalent to the OP code. The my only applies to $JAN.

    my $JAN = my $FEB = my $MAR .... my $DEC = 0; would be better.

    However I suspect another data structure would better suit the OP's ultimate purpose, perhaps an array @Month_Whatever where $Month_Whatever[0] is January's figure etc.

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
Re^2: multiple variable initialization in one line
by jmcnamara (Monsignor) on Jan 31, 2005 at 14:25 UTC

    The first example should be:
    my ($JAN,$FEB,$MAR,$APR,$MAY,$JUN,$JUL,$AUG,$SEP,$OCT,$NOV,$DEC) = (0) + x 12;
    See "Multiplicative Operators" in perlop.

    --
    John.

Re^2: multiple variable initialization in one line
by Anonymous Monk on Jan 31, 2005 at 14:18 UTC
    Perfection! (and not just a help-less redirect)
    Thanks!... that was exactly what I was looking for. :)