Foren » forum (Archiv) »
perl map
Von Werner Hahn vor mehr als 9 Jahren hinzugefügt
Hallo
map() ist mir noch ein bisschen ein Rätsel
habe 2 Arrays und brauche bestimmte Daten aus dem einem für das andere. Geht das mit map?
@shopimportitems => [
{
description => 'eins',
partnumber => '1',
quantity => 6,
price => 2.5,
...
},
{
description => 'zwei',
partnumber => '2',
quantity => 4,
price => 2.5,
...
},
];
@parts => [
{
id => 1,
description => 'eins',
partnumber => '1',
...
},
{
id => 2,
description => 'zwei',
partnumber => '2',
},
{
id => 3,
description => 'drei',
partnumber => '3',
...
},
{
id => 4,
description => 'vier',
partnumber => '4',
},
{
id => 5,
description => 'fuenf',
partnumber => '5',
...
},
{
id => 6,
description => 'sechs',
partnumber => '6',
...
},
];
#gebraucht für orderitems
@orderitems => [
{
id => 1, # zugehörige id aus @parts
description => 'eins', # aus @shopimportitems
partnumber => '1', # aus @shopimportitems
quantity => 6, # aus @shopimportitems
price => 2.5, # aus @shopimportitems
...
},
{
id => 2, # zugehörige id aus @parts
description => 'zwei', # aus @shopimportitems
partnumber => '2', # aus @shopimportitems
quantity => 4, # aus @shopimportitems
price => 2.5, # aus @shopimportitems
...
},
];
Antworten (1)
RE: perl map - Von Bernd Bleßmann vor mehr als 9 Jahren hinzugefügt
Hallo Werner,
ich denke das geht gut mit: pairwise aus List::MoreUtils
da findest Du auch schon Anwendungen im Code (z.B. auch im neuen Order-Controller).