use strict;
use warnings;
sub test {
my %comments_of_url = ();
open FILE, "<D:/Codesnippets/Perl/abc.txt" or die $!;
while (<FILE>) {
# Skip empty lines
next if /^\s*$/;
# Use url as key and #xxx as value for each line
# Merge all the #xxx for a url
if (/amscript_cd\("(.*?)"\)\){__amscript_wc\('(.*?)\s+\{/) {
$comments_of_url{ $1 } .= ( $2 . ',' );
}
}
foreach my $key (keys %comments_of_url) {
chomp (my $value = $comments_of_url{$key});
print q{Lif(__amscript_cd("};
print $key;
print q#")){__amscript_wc('#;
print $value;
print q#{display:none;}');};#;
print "\n";
}
}
sub main {
&test();
}
&main();
1
==