in reply to array assignment

map makes this easy:
@a = (1,2,3); @b = (4,5,6); @result = map {$a[$_]+$b[$_]} 0..$#a;

-Mark

Replies are listed 'Best First'.
Re^2: array assignment
by Roy Johnson (Monsignor) on Nov 13, 2004 at 02:55 UTC
    Applying that to the date problem:
    my ($dd, $mm, $yyyy) = map {(0,1,1900)[$_] + ((localtime)[3..5])[$_]} +0..2;
    Not real pretty, but I guess that's why Tye invented Mapcar, which, if I read the docs right, one could use to solve the problem thus:
    my ($dd, $mm, $yyyy) = mapcar { $_[0] + $_[1] } [0,1,1900], [(localtim +e)[3..5]];
    (no extra map needed, Dragonchild).

    Caution: Contents may have been coded under pressure.