From rhector at actrix.gen.nz Mon Oct 7 02:07:25 2002 From: rhector at actrix.gen.nz (Richard Hector) Date: Thu Aug 5 00:24:14 2004 Subject: Perl & emacs Message-ID: <1033974447.703.4.camel@diamond> Hi all, I typed in something similar (more complex than) the following the other day: /(foo$)/ That, I think, is a simple, valid regular expression. But emacs thinks the parentheses are mismatched - presumably it thinks that $) is a variable (which I believe it isn't in this context). I find it hard to believe that no-one would have met this before - is it a well known problem? Thanks, Richard From piers at ompa.net Mon Oct 7 03:11:02 2002 From: piers at ompa.net (Piers Harding) Date: Thu Aug 5 00:24:14 2004 Subject: Perl & emacs In-Reply-To: <1033974447.703.4.camel@diamond>; from rhector@actrix.gen.nz on Mon, Oct 07, 2002 at 08:07:25PM +1300 References: <1033974447.703.4.camel@diamond> Message-ID: <20021007091102.A20121@gnu> Hmm - which version of emacs is it? I have just tried this out on Emacs 21.2.1 - Linux RH 8.0, and it seems fine. Cheers. On Mon, Oct 07, 2002 at 08:07:25PM +1300, Richard Hector wrote: > Hi all, > > I typed in something similar (more complex than) the following the other > day: > > /(foo$)/ > > That, I think, is a simple, valid regular expression. But emacs thinks > the parentheses are mismatched - presumably it thinks that $) is a > variable (which I believe it isn't in this context). > > I find it hard to believe that no-one would have met this before - is it > a well known problem? > > Thanks, > > Richard > From rhector at actrix.gen.nz Mon Oct 7 17:37:31 2002 From: rhector at actrix.gen.nz (Richard Hector) Date: Thu Aug 5 00:24:14 2004 Subject: [Fwd: Re: Perl & emacs] Message-ID: <1034030252.360.1.camel@diamond> Oops, sorry, this was meant for the list ... -----Forwarded Message----- > From: Richard Hector > To: Piers Harding > Subject: Re: Perl & emacs > Date: 07 Oct 2002 23:41:21 +1300 > > On Mon, 2002-10-07 at 21:11, Piers Harding wrote: > > > > On Mon, Oct 07, 2002 at 08:07:25PM +1300, Richard Hector wrote: > > > > > > /(foo$)/ > > > > > > That, I think, is a simple, valid regular expression. But emacs thinks > > > the parentheses are mismatched - presumably it thinks that $) is a > > > variable (which I believe it isn't in this context). > > > > > Hmm - which version of emacs is it? I have just tried this out on Emacs > > 21.2.1 - Linux RH 8.0, and it seems fine. > > 21.2.1 on Debian 3.0, ?? on NetBSD (at VUW), 20.7.2 on Debian 3.0. > > I just open a buffer with a .pl extension so that emacs knows what it > is, paste the aboce in, and double-click on the opening paren. That > should highlight the parenthesised expression, but it beeps and flashes > this message: > > Scan error: "Unbalanced parentheses", 2, 9 > > Richard > From don at gamma.net.nz Tue Oct 8 03:37:45 2002 From: don at gamma.net.nz (Don Jones) Date: Thu Aug 5 00:24:14 2004 Subject: Perl tip of the day (was Re: Wellington Perlmongers) In-Reply-To: <20020925173159.B21400@gnu> References: <5FA042F680739D44951B00FED8BE1A7D05DBC1@dasher.webdom1.web.co.nz> <20020925173159.B21400@gnu> Message-ID: <20021008083745.M79622@gamma.net.nz> 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. 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? Personaly I dont like the idea much, but there seems to be a big market for 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? 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 () { 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 ;) 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@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 From piers at ompa.net Tue Oct 8 04:03:43 2002 From: piers at ompa.net (Piers Harding) Date: Thu Aug 5 00:24:14 2004 Subject: Perl tip of the day (was Re: Wellington Perlmongers) In-Reply-To: <20021008083745.M79622@gamma.net.nz>; from don@gamma.net.nz on Tue, Oct 08, 2002 at 08:37:45PM +1200 References: <5FA042F680739D44951B00FED8BE1A7D05DBC1@dasher.webdom1.web.co.nz> <20020925173159.B21400@gnu> <20021008083745.M79622@gamma.net.nz> Message-ID: <20021008100343.C2929@gnu> 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 () { > 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@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 From don at gamma.net.nz Wed Oct 9 19:20:00 2002 From: don at gamma.net.nz (Don Jones) Date: Thu Aug 5 00:24:14 2004 Subject: Calling perl from a SSI Message-ID: <20021010002000.M65152@gamma.net.nz> Hi - Im not much of a web developer but an tryingto to something you guys may be able to help with: I want to run a perl script every time a certain html page is accessed, the script doesnt need to write anything back to the browser so doesnt need to be GCI but I want to pass it variables from the html page - some of the variables are javascript variables used in the html and others are just the environment variables HTTP_USER_AGENT & REMOTE_ADDR, it seems that either i should make the page a cgi - but it has quite a bit of java script in it so this is not that appealing, or I thought i could just call the perl script using SSI exec but im not sure you can pass args via SSI - does anyone know how to do this? Am i missing some other obvious way of doing this? the perl script would just write a line to a log file using the variables passed to it. Ideas appreciated Don Jones -- "Intellectual Property" : a tool that the dinosaurs use to make sure there are no mammals in the future. - Lawrence Lessig From grantm at web.co.nz Wed Oct 9 19:07:22 2002 From: grantm at web.co.nz (Grant McLean) Date: Thu Aug 5 00:24:14 2004 Subject: Calling perl from a SSI Message-ID: <3DA4C4BA.7010107@web.co.nz> One way to do it would be to include an image tag in your HTML like this: Then yourscript.pl can do what it needs to do before redirecting to a 1 pixel transparent GIF (or PNG depending on your patent position - and I believe yours is hanging on the line for all to see :-) ). Grant =============================================================== Grant McLean BearingPoint Inc - formerly The Web Limited +64 4 495 8250 Level 6, 20 Customhouse Quay, Box 1195 gmclean@bearingpoint.biz Wellington, New Zealand > -----Original Message----- > From: Don Jones [mailto:don@gamma.net.nz] > Sent: Thursday, October 10, 2002 1:20 PM > To: wellington-pm-list@pm.org > Subject: Calling perl from a SSI > > > Hi - Im not much of a web developer but an tryingto to > something you guys may > be able to help with: > > I want to run a perl script every time a certain html page is > accessed, the > script doesnt need to write anything back to the browser so > doesnt need to be > GCI but I want to pass it variables from the html page - some > of the variables > are javascript variables used in the html and others are just > the environment > variables HTTP_USER_AGENT & REMOTE_ADDR, it seems that either > i should make > the page a cgi - but it has quite a bit of java script in it > so this is not > that appealing, or I thought i could just call the perl > script using SSI exec > but im not sure you can pass args via SSI - does anyone know > how to do this? > > Am i missing some other obvious way of doing this? > > the perl script would just write a line to a log file using > the variables > passed to it. > > Ideas appreciated > > Don Jones > > -- > "Intellectual Property" : a tool that the dinosaurs use to make sure > there are no mammals in the future. - Lawrence Lessig > > From piers at ompa.net Sat Oct 19 07:31:42 2002 From: piers at ompa.net (Piers Harding) Date: Thu Aug 5 00:24:14 2004 Subject: Inline::BC Message-ID: <20021019133142.A26106@gnu> Hi, For those interested in Inline, I have just released a new Language support module for Gnu bc ( the arbitrary precision maths language ) called Inline::BC - http://search.cpan.org/search?query=Inline%3A%3ABC&mode=module Cheers.