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: [$0.05$] duplicates in an array?: Edit Log



$0.05$
Novice

Jun 1, 2002, 5:27 PM


Views: 3733
Re: [$0.05$] duplicates in an array?

and it isnt working - perhaps theres a flaw in my code




Code
    

#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';

print "Content-type:text/html\n\n";


$action = param('action');
$input = param('first');

if ($action eq "1"){
sort_array();
}
else {
main();
}

sub main{
print qq(
Insert all email addresses in here<br>
<form action ="sort.pl" method="post">
<input type="hidden" name="action" value="1">
<textarea name="first" rows="10" cols="40"></textarea><br>
<input type="submit" value="Let's get rid of those dup's!">
</form>
);

}

sub sort_array{
print "Sorting..<br>";
(@input_done) = split(/\n/, $input);
@sorted = sort { $a <=> $b } @input_done;

@no_duplicates1 = grep !$seen{$_}++, @sorted;

print qq(<textarea rows="10" cols="40">);
foreach $thing (@no_duplicates1){
print "$thing\n";
}
print qq(</textarea>);

}



i will input this


Code


and get this
ryan@lonegamers.com--
blah@blan.com--
blah@blah.com--



(This post was edited by $0.05$ on Jun 1, 2002, 5:28 PM)


Edit Log:
Post edited by $0.05$ (Novice) on Jun 1, 2002, 5:28 PM


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

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