Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use Cwd qw(cwd);
  4. my $dir = cwd;
  5.  
  6. print "$dir\n";
  7.  
  8. my $filename = "$dir/data/adzuna.html";
  9.  
  10.  
  11. my $counter = 1;
  12. my $content;
  13. open(my $fh, '<', $filename) or die "cannot open file";
  14. {
  15. local $/;
  16. $content = <$fh>;
  17. }
  18. close($fh);
  19.  
  20.  
  21. my @countries;
  22. my @sorted_countries;
  23.  
  24. @countries = ( $content =~ /<a href="https:\/\/www\.adzuna\.\w+\.?\w*">([^<]+?)<\/a>/g );
  25.  
  26. @sorted_countries = sort { lc($a) cmp lc($b) } @countries;
  27. foreach my $country (@countries)
  28. {
  29. print "$counter:";
  30.  
  31. if ( length($country) < 4 )
  32. {
  33. print "$country\t\t$sorted_countries[$counter-1] \n";
  34. }
  35. else
  36. {
  37. print "$country\t$sorted_countries[$counter-1] \n";
  38. }
  39. $counter++;
  40. }
  41.  
  42. 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement