in reply to Re^3: how to sort uniq $array[2]
in thread how to sort uniq $array[2]
well $array2 -is third field of a file that has been split by / @array -contains all fields when i did like you said i got error - sort:open failed no such file or directory it shouldn't be all that complex i think instead of www.google.ie www.google.ie www.google.ie to get: www.google.ie
#!/usr/bin/perl -w use strict; find_serv (); sub find_serv { @ARGV == 2 || die "usage: $0 INDEX_FILE '.com'\n";# .com---->icq.com my ( $INDEX_FILE, $com ) = @ARGV; my $list = "grep 'href=' $INDEX_FILE|" ;#- $INDEX_FILE --> wget www. +icq.com open (my $HAN, "$list" ) || die "Cannot open '$INDEX_FILE' because:: +$!"; while (<$HAN>) { chomp $_; my @array = split (/\//, $_); if ($array[2] =~ /$com/ ){#matches icq.com my @sort = $array[2]; #my $result = `sort -u '$sorted'`; #print "$result\n"; system "sort -u '$array[2]' > '$array[2].sorted'"; rename "$array[2].sorted", $array[2]; print "$array[2]n"; }} } #END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: how to sort uniq $array[2]
by JavaFan (Canon) on Jun 06, 2011 at 18:36 UTC |