CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [BillKSmith] Removal of duplicated element in array with order.: Edit Log



Wazezu
Novice

May 7, 2013, 1:24 AM


Views: 628
Re: [BillKSmith] Removal of duplicated element in array with order.

I modified the code you provided into the relevant part of my codes. Perhaps there's an error ?

The output still consists of duplicates.

I attached the test html file below.


Code
 
#!/usr/bin/perl w

use strict;
use warnings;
use Cwd;

foreach my $argnum (0 .. $#ARGV) {

if ($ARGV[$argnum] eq "-ft"){

my $perl_path = cwd;

if(-e 'testht.html') {

open(OPENFILE, "$perl_path/testht.html") or die "Unable to open file";
}

my @email = <OPENFILE>;
close OPENFILE;

foreach my $email (@email){

if ($email =~ /(\w[-.\w]*\@[a-z0-9]+(\.[-a-z0-9]+)*\.(com|edu|info|net|org|gov))/){
my $match = "$1";
#print "$match\n";

my @raw_data = split /\n/, $match;

my @match_to_array = map {/($email)/; $1} @raw_data;

my %seen;
my @r = map {$seen{$_}++ ? () : $_} @match_to_array;

{local $, = "\n"; print @r, "\n";}

} # end of if statement

} # end of foreach


} # end of elsif -ft

}



(This post was edited by Wazezu on May 7, 2013, 1:24 AM)
Attachments: testht.html (74 B)


Edit Log:
Post edited by Wazezu (Novice) on May 7, 2013, 1:24 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives