Skip to content

Instantly share code, notes, and snippets.

@nordicdyno
Last active December 23, 2015 04:48
Show Gist options
  • Select an option

  • Save nordicdyno/6582314 to your computer and use it in GitHub Desktop.

Select an option

Save nordicdyno/6582314 to your computer and use it in GitHub Desktop.
use strict;
my $h_file = '/private/etc/hosts';
open my $fh_in, '<', $h_file or die "Can't read file $h_file: $!";
my @lines;
while(<$fh_in>) {
push @lines, $_;
}
close $fh_in;
open my $fh_out, '>', $h_file or die "Can't write to $h_file: $!";
for (@lines) {
next if /^[0-9.]+\s+ua\.tribuna\.com/;
next if /^[0-9.]+\s+sports\.ru/;
next if /^[0-9.]+\s+www\.sports\.ru/;
print ${fh_out} $_;
}
close $fh_out;
`killall -HUP mDNSResponder`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment