
$0.05$
Novice
Jun 1, 2002, 5:27 PM
Views: 2427
|
|
Re: [$0.05$] duplicates in an array?
|
|
|
and it isnt working - perhaps theres a flaw in my 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 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)
|