Smith has asked for the wisdom of the Perl Monks concerning the following question:
Still pretty weak on using hashes so I am hoping someone could please help. Im opening a file with domains in them and then pulling out only the root domain. Then I am trying to use the hash and grep to remove any duplicates but all I get back are blank lines.
#!/usr/bin/perl $upload = "/var/tmp/work/upload"; $work = "/var/tmp/work/"; $input3 = "$upload/domain.csv"; system ("dos2unix $input3"); open (IN,"$input3"); open (OUT,">>$work/local.rules"); while (<IN>) { chomp(); if ($_ =~ /^.+\.([A-Za-z0-9-_]+\.[A-Za-z]{2,})$/){ $domain = $1; %seen = (); @unique = grep { ! $seen{ $domain }++ } @array; print "@unique\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: remove duplicates with hash and grep
by LanX (Saint) on Dec 22, 2014 at 21:29 UTC | |
by Smith (Initiate) on Dec 22, 2014 at 22:04 UTC | |
by GotToBTru (Prior) on Dec 22, 2014 at 22:18 UTC | |
by Smith (Initiate) on Dec 23, 2014 at 15:19 UTC | |
by AnomalousMonk (Archbishop) on Dec 23, 2014 at 04:25 UTC | |
|
Re: remove duplicates with hash and grep
by toolic (Bishop) on Dec 22, 2014 at 21:29 UTC | |
|
Re: remove duplicates with hash and grep
by Smith (Initiate) on Dec 22, 2014 at 21:30 UTC |