Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

count and sort url in text file

hello there,

i have this code which gets all the url from a text file.now i want to also get the number of times that url is in the text file and then sort them according to their numbers.
for example
https://www.experts-exchange.com 50
http://www.gmail.com 44
http://www.yahoo.com 40

cheers
zolf
Avatar of Zolf
Zolf
Flag of United Arab Emirates image

ASKER

this is my code
#!/usr/bin/perl

@arr = <IN>;

foreach $i (@arr)
{
      @arr1 = split('\s+',$i);
      foreach $j (@arr1)
      {
          if($j =~ /^http:\/\/(.*)$/ig)
           {
                   print $j."\n";
ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

If you are on a unix system, you can do:

sort file | uniq -c | sort -rn

Avatar of Zolf

ASKER


no i am not