in reply to stripping an array

what is the shortest way?

I don't know about shortest. Don't feel like playing golf today, sorry :)

# untested my %foo = map { split /,/, $_, 2 } @arr2; my @arr3 = map { exists $foo{$_} ? $foo{$_} : () } @arr1;
Your arrays need better names. So does my %foo.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re: Re: stripping an array
by steves (Curate) on Jan 02, 2003 at 18:19 UTC

    I tested this one. It works and wins my vote for shortest and cleanest.

      But you're wrong. :-)
      my @arr3 = @foo{@arr1};

      And if you don't mind very short but somewhat dirty, you can do this:
      my %foo = map{/,/;$`,$'} @arr2;

      jdporter
      The 6th Rule of Perl Club is -- There is no Rule #6.