Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Help with removing duplicates in array

by beanscake (Acolyte)
on Mar 27, 2015 at 12:36 UTC ( [id://1121496]=note: print w/replies, xml ) Need Help??


in reply to Re: Help with removing duplicates in array
in thread Help with removing duplicates in array

ok thanks, i mean it's not removing duplicates as i intended it to work.. please if you can put this to a txt and run the script and see it's not removing these duplicates =>'aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net';
The beginning of knowledge is the discovery of something we do not understand.
    Frank Herbert (1920 - 1986)

Replies are listed 'Best First'.
Re^3: Help with removing duplicates in array
by hippo (Bishop) on Mar 27, 2015 at 13:44 UTC

    Are you perhaps confusing a string with a list?

    use strict; use warnings; use feature 'say'; sub uniq { #and this to handle the duplicated emails return keys %{ { map { $_ => 1 } @_ } }; } my $string = 'aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa +@jjj.net aaaa@jjj.net aaaa@jjj.net'; say "string: ", join ' ', uniq($string); say "list: ", join ' ', uniq(split(/ /, $string));

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-29 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found