Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

perl: remove elements of array2 from array1

Name: Anonymous 2010-05-14 6:41

Hi, I'm learning perl programming and would appreciate some help. How do I write code to remove elements of array2 from array1

I.e.

@array1={'a','b','c','d'}
@array2={''a','z','c','x'}


(magic happens, processes @array1 and @array2)

dump @array1 gives 'b','d'

Any clues?

Thanks!

Name: Anonymous 2010-05-14 13:21

>>> array1 = {'a', 'b', 'c', 'd'}
>>> array2 = {'a', 'z', 'c', 'x'}
>>> array1 -= array2
>>> array1
{'b', 'd'}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List