in reply to Re^2: how to sort uniq $array[2]
in thread how to sort uniq $array[2]

But what is $array[2]? A name of a file? In that case, take my previous answer, and replace $scalar with $array[2].

Replies are listed 'Best First'.
Re^4: how to sort uniq $array[2]
by auto_w (Novice) on Jun 06, 2011 at 15:00 UTC

    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
      well $array[2] -is third field of a file that has been split by /
      Actually, $array[2] is the third field of a line. (And will be the third field of every line).
      @array -contains all fields
      Of each line. But since you are only using $array[2], the rest of the array is irrelevant.
      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
      Maybe, instead of showing us code with "it doesn't work", you can tell us what data you have, and what output you would like to get.

      Because from your description, I've no fucking clue where the www.google.ie's are supposed to be.