[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] sherlock banner-killer



Someone wrote a C program to do kill sherlock banners.  Here is the source:

    http://www.ogopogo.net/products/banner-free/banner-free.src.sit.hqx

Compare its code to strip banners (including the lex file!) and this Perl
program (posted before) and wonder out loud why we love Perl.  :)

#!perl -w
# killsherlockbanners.plx
# by pudge@pobox.com

use strict;
use Mac::Files;

chdir(FindFolder(kOnSystemDisk, kSystemFolderType)
    . ':Internet Search Sites:') or die "Can't find plugin directory: $!\n";
my @files = <*.src>;

foreach my $f (@files) {
    local $/;
    open(FILE, "+<$f") or die "Can't open $f: $!\n";
    my $file = <FILE>;
    (my $new = $file) =~ s/^\s*banner(start|end)\b.*$//mgi;
    if ($new ne $file) {
        truncate(FILE, 0);
        seek(FILE, 0, 0);
        print FILE $new;
        $f =~ s/\.src$//;
        print "Killed ads in $f\n";
    }
    close(FILE);
}
__END__

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch