On Aug 30, david said: >Ramprasad A Padmanabhan wrote: > >> Hi All, >> I have been using perl on linux for quiet some time now and I have >> found that Perl does not work the same in windows >> >> eg. To get all the unique elements of an array in linux I use a >> simple one liner >> >> @unique = grep{!/$seen{$_}++/} @all_elements; >> >> But this does not even pass syntax check on windows >> Can Anyone tell me the best way how to get all the unique elements in an >> array preserving the same order > >why not simply: > >@hash{@all_elements} = (); > >now "keys %hash" gives you the unique elements.
It's faster, but you lose the order. You could always use my Tie::Array::Unique module... -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]