Perl tip of the day (was Re: Wellington Perlmongers)
Piers Harding
piers at ompa.net
Tue Oct 8 04:03:43 CDT 2002
Reply inline...
On Tue, Oct 08, 2002 at 08:37:45PM +1200, Don Jones wrote:
> Peirs
>
> exactly what problem where you trying to solve that prompted you to write a
> Perl based HTTP proxy? I did have a look at your site - i think you mentioned
> something about SSL.
It was curiosity as much as anything. I wanted to go through the
process of understanding how a browser interacts with a proxy, and I
wanted to understand a bit more about SSL. I did actually have a
problem to solve, in that the website I am building for work is using
the AxKit, and I wanted to beable to inspect the HTTP Headers, and and
or content as it flowed back and forth between client and server.
>
> Talking of http proxys, content filtering is all the rage these days, I have
> inplemented squidguard on squid before (dont remember if its perl or not) and
> have recently looked into snapgear firewalls which have content filtering from
> cerberian -generally this stuff tends to be written in perl (eg spamassassin
> and various conercial products that ride ontpo of it like perlmx and
> spamassassin.com)
>
> So - the question - are there any open source http content filters out there?
I don't know, but I suspect that they would have to be grafted onto
something like Squid for performance reasons - which wouldn't be that
hard to do. The hardest thing ( to me ) would be coming up with a
good rules based engine for the filtering.
>
> Personaly I dont like the idea much, but there seems to be a big market for
Yes - I don't like them either - too much like censorship for my liking.
> them - and in New Zealand at least the 90% answer seems to be web marshal, and
> mail marshal - are there any perl based alternatves
>
> I wonder what extras and ihugs virus filters are - I would think they run on
> unix - any ideas?
No - sorry.
>
> btw heres some code I did last friday in response to a post on the NZNOG
> mailing list - it checks banners for nz isps MTAs, it should be easy to modify
> to test if the MTA allows forged from addresses which was what the origional
> post was about but i didnt add that - too spammer friendly.
>
> any constructive criticism appreciated (code not email style :)
>
> usage ./banner.pl nz_ips.txt
>
> #!/usr/bin/perl -w
>
> use strict;
> use Net::Telnet;
> use Net::DNS;
>
> my $isps = shift;
>
> open (ISPS, "<$isps") or die "can't open $isps: $!";
>
> while (<ISPS>) {
> chomp;
> print "-------------------------------------------------------\n";
> print "ISP = $_\n";
>
> my $res = new Net::DNS::Resolver;
> my @mx = mx($res, $_);
> if (@mx) {
> foreach my $rr (@mx) {
> print $rr->preference, " ", $rr->exchange, "\n";
>
>
> my $telnet = new Net::Telnet ( Timeout=>30,
> Port=>25,
> Errmode=>'die');
> $telnet->open($rr->exchange,);
> $telnet->waitfor('/220/');
> $telnet->print('helo just-testing.org');
> (my $output)=$telnet->waitfor('/250/');
> $telnet->print('quit');
>
> print "Banner: $output";
> }
> }
> else {
> print "can't find MX records for $_: ", $res->errorstring,
> "\n"; }
>
> Sorry about the rambling post - im drinking beer as I write ;)
Cool - I wish I was :-), but I'm at work ( 9:39 BST ).
Cheers.
>
> Don
>
>
> > Excellent - altho I don't ( fortunately ) have the problem of using
> > win32. :-)
> >
> > I have written a couple of articles lately, and attended OSCON so
> > perhaps people might be intereseted in such subjects as Perl based HTTP
> > proxies, embedding Perl in Daemons, and Perl and SAP R/3.
> > My blitherings are at:
> > http://www.piersharding.com.
> >
> > Cheers.
> >
> > On Wed, Sep 25, 2002 at 09:43:03PM +1200, Grant McLean wrote:
> > > Hi Piers
> > >
> > > Just to let you know we're not all ignoring you. I couldn't reply
> > > straight away since I was writing Tcl code :-(
> > >
> > > I'm all in favour of a bit more 'banter' on the list. What would
> > > you like to talk about?
> > >
> > > Perhaps since no one is asking questions, I could kick off with an
> > > unsolicited answer...
> > >
> > >
> > > Today's message is brought to you be the command line argument '-l'.
> > >
> > > The problem:
> > > I want to extract a list of subroutine names from a Perl .pm file.
> > >
> > > The solution:
> > >
> > > perl -n -e '/^\s*sub\s+(\w+)/ && print "$1\n"' filenames
> > >
> > > Unfortunately, although that works nicely on Unix, it doesn't work
> > > on Windows. At least not with the standard Windows command shell
> > > which only recognises double quotes. One alternative is to use
> > > the 'qq' double quoting operator:
> > >
> > > perl -n -e "/^\s*sub\s+(\w+)/ && print qq($1\n)" filenames
> > >
> > > But my tip of the day is to dispense with the quotes and use the
> > > '-l' option to append a linefeed onto every print:
> > >
> > > perl -nle "/^\s*sub\s+(\w+)/ && print $1" filenames
> > >
> > > Which is less typing too.
> > >
> > > Anyone else have a tip?
> > >
> > > Regards
> > > Grant
> > >
> > >
> > > > -----Original Message-----
> > > > From: Piers Harding [mailto:piers at ompa.net]
> > > > Subject: Re: Wellington Perlmongers
> > > >
> > > >
> > > > Hi Guys - I listen into the melbourne.pm list, and they seem to share
> > > > lots of ideas, and regularily publish work/articles etc. to the list.
> > > > Are people on this list interested in the same sort of thing, as it
> > > > would be good to try and inject some life back into it?
> > > >
> > > > Also, as a kiwi overseas, it would be nice to have some
> > > > banter with the
> > > > Perl community back home.
> > > >
> > > > Cheers.
> > > >
> > > > Piers Harding
>
>
> --
> "Intellectual Property" : a tool that the dinosaurs use to make sure
> there are no mammals in the future. - Lawrence Lessig
More information about the Wellington-pm
mailing list