Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Perl one-liner to remove duplicate entries from PATH

by demerphq (Chancellor)
on Jan 12, 2006 at 18:57 UTC ( [id://522780]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl one-liner to remove duplicate entries from PATH
in thread Perl one-liner to remove duplicate entries from PATH

my %path; $path{$_}=$path{$_} || 1 + keys %path for split /$sep/,$path;

there are other more efficient ways to do that btw, im just feeling moderately cheeky. ;-)

And for the curious you cant write that as ||= because of a bug in Perl (on some versions of Perl anyway).

Update:

Or maybe its not a bug. According to some the docs should be read to say that it should be valid to say

my %path; $path{$_}||=keys %path for split /$sep/,$path;

and some are saying that the results are undefined. sigh

---
$world=~s/war/peace/g

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522780]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found