删除重复行

时间:2017-05-14 09:36:45

标签: perl

#!/usr/bin/perl

use Term::ANSIColor;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request;
use HTTP::Request::Common qw(POST);
$ua = LWP::UserAgent->new(keep_alive => 1);
$ua->agent("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
$ua->timeout (10);

print "scan\n";
$site="http://aubergelasolas.com\n";

$sorm = $ua->get($site);
$karza = $sorm->content;
while($karza =~m/\/wp-content\/plugins\/(.*?)\/(.*?)' type='text\/css' media='all'/g)
{ 
$id=$1;
print "[*] Plugins: $id \n";

}

如果运行脚本字体这个rzlt 我需要删除或隐藏重复

perl k.pl
scan
[*] Plugins: google-language-translator
[*] Plugins: jetpack
[*] Plugins: our-team-enhanced
[*] Plugins: wc-gallery
[*] Plugins: wc-gallery
[*] Plugins: wc-gallery
[*] Plugins: wc-gallery
[*] Plugins: wc-gallery
[*] Plugins: tablepress

我只需删除重复的行 我需要删除或隐藏重复 和thnx

1 个答案:

答案 0 :(得分:0)

my %seen; # Hash for counting number of occurrences
while($karza =~m/\/wp-content\/plugins\/(.*?)\/(.*?)' type='text\/css' media='all'/g)
{ 
  $id=$1;
  next if $seen{$id}++; # skip already seen ids
  print "[*] Plugins: $id \n";
}