Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env perl | |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | package WebCrawler; | |
6 | ||
7 | sub uniq(\@) { | |
8 | my ($i) = @_; | |
9 | my %h; | |
10 | @h{@$i} = (); | |
11 | @$i = keys %h; | |
12 | return(@$i); | |
13 | } | |
14 | ||
15 | sub unique(\@) { | |
16 | my ($i) = @_; | |
17 | my %h; | |
18 | @$i = grep(!$h{$_}++, @$i); | |
19 | return(@$i); | |
20 | } | |
21 | ||
22 | my @b = qw(b b c c c a a d); | |
23 | print "@b\n"; | |
24 | unique(@b); | |
25 | print "@b\n"; |