From nico at itfirms.co.za Sun Jun 1 02:51:11 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE Message-ID: <200306010951.11391.nico@itfirms.co.za> Hi there list members :) I have updated the home page, http://za.pm.org/ with some news. Please have a look, and discuss in here. With this latest - perhaps crazy - idea of mine, I would like to propose the following focus areas for the comming weeks: 22-28 June 2003 -> Variable types ( scalars, arrays and hashes ) 29 June to 5 July 2003 -> Using modules 6 - 19 July 2003 -> regex's (this is usually a hot topic, hence two weeks) If you think this is crazy, let me know - on the other hand, if you would like to suggest something else - let's here about it. Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From oskar at qualica.com Mon Jun 2 02:57:20 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE In-Reply-To: <200306010951.11391.nico@itfirms.co.za> References: <200306010951.11391.nico@itfirms.co.za> Message-ID: <20030602075720.GS17622@qualica.com> Hi On Sun, Jun 01, 2003 at 09:51:11AM +0200, Nico Coetzee wrote: > > Hi there list members :) > > I have updated the home page, http://za.pm.org/ with some news. Please have a > look, and discuss in here. > > With this latest - perhaps crazy - idea of mine, I would like to propose the > following focus areas for the comming weeks: > > 22-28 June 2003 -> Variable types ( scalars, arrays and hashes ) > 29 June to 5 July 2003 -> Using modules > 6 - 19 July 2003 -> regex's (this is usually a hot topic, hence two weeks) > > If you think this is crazy, let me know - on the other hand, if you would like > to suggest something else - let's here about it. I like this idea; perhaps it needs to be nailed down more (ie more detail), or should someone be given responsibility to create a set of posts that discusses things, like 1 per day or something? I'll volunteer for doing some of this if you want. I wonder if I should do something like this for the glug-tech list. hmm. Oskar From fuzzylogik at webmail.co.za Mon Jun 2 03:28:45 2003 From: fuzzylogik at webmail.co.za (Dallas G) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE References: <200306010951.11391.nico@itfirms.co.za> <20030602075720.GS17622@qualica.com> Message-ID: <002e01c328e0$fce24b20$a802000a@realm.co.za> Hi I would love to do this.. being a perl newbie i think these would be a great way to learn. I would like to write some tuts, this way forces me to learn is this going to be meetings, or tuts on the website? Regards Dallas Goldswain ----- Original Message ----- From: "Oskar Pearson" To: "Nico Coetzee" Cc: Sent: Monday, June 02, 2003 9:57 AM Subject: Re: [Za-pm] UPDATE Hi On Sun, Jun 01, 2003 at 09:51:11AM +0200, Nico Coetzee wrote: > > Hi there list members :) > > I have updated the home page, http://za.pm.org/ with some news. Please have a > look, and discuss in here. > > With this latest - perhaps crazy - idea of mine, I would like to propose the > following focus areas for the comming weeks: > > 22-28 June 2003 -> Variable types ( scalars, arrays and hashes ) > 29 June to 5 July 2003 -> Using modules > 6 - 19 July 2003 -> regex's (this is usually a hot topic, hence two weeks) > > If you think this is crazy, let me know - on the other hand, if you would like > to suggest something else - let's here about it. I like this idea; perhaps it needs to be nailed down more (ie more detail), or should someone be given responsibility to create a set of posts that discusses things, like 1 per day or something? I'll volunteer for doing some of this if you want. I wonder if I should do something like this for the glug-tech list. hmm. Oskar _______________________________________________ Za-pm mailing list Za-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/za-pm From oskar at qualica.com Mon Jun 2 03:39:09 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE In-Reply-To: <002e01c328e0$fce24b20$a802000a@realm.co.za> References: <200306010951.11391.nico@itfirms.co.za> <20030602075720.GS17622@qualica.com> <002e01c328e0$fce24b20$a802000a@realm.co.za> Message-ID: <20030602083909.GY17622@qualica.com> Hi > I would love to do this.. > being a perl newbie i think these would be a great way to learn. > I would like to write some tuts, this way forces me to learn More as an aside than anything else. http://www.linux.org.za/whole-perl-tutorial.txt I learned my first perl from that - quite cool. Oskar From fuzzylogik at webmail.co.za Mon Jun 2 03:43:19 2003 From: fuzzylogik at webmail.co.za (Dallas G) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE References: <200306010951.11391.nico@itfirms.co.za> <20030602075720.GS17622@qualica.com> <002e01c328e0$fce24b20$a802000a@realm.co.za> <20030602083909.GY17622@qualica.com> Message-ID: <00a101c328e3$068061b0$a802000a@realm.co.za> thanks I see there are hundreds of extra libs for perl, CPAN are they all optional? can you recomend which are good to have for generic web page/db interaction thanks Dallas ----- Original Message ----- From: "Oskar Pearson" To: "Dallas G" Cc: Sent: Monday, June 02, 2003 10:39 AM Subject: Re: [Za-pm] UPDATE Hi > I would love to do this.. > being a perl newbie i think these would be a great way to learn. > I would like to write some tuts, this way forces me to learn More as an aside than anything else. http://www.linux.org.za/whole-perl-tutorial.txt I learned my first perl from that - quite cool. Oskar _______________________________________________ Za-pm mailing list Za-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/za-pm From contrafa at biology.und.ac.za Mon Jun 2 04:16:45 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - UPDATE In-Reply-To: <200306011701.h51H1LX03717@mail.pm.org> References: <200306011701.h51H1LX03717@mail.pm.org> Message-ID: <1054545405.13460.9.camel@contra.biology.und.ac.za> On Sun, 2003-06-01 at 19:00, za-pm-request@mail.pm.org wrote: > From: Nico Coetzee > To: za.pm.org > Subject: [Za-pm] UPDATE > Date: 01 Jun 2003 09:51:11 +0200 > > > Hi there list members :) > > I have updated the home page, http://za.pm.org/ with some news. Please have a > look, and discuss in here. > > With this latest - perhaps crazy - idea of mine, I would like to propose the > following focus areas for the comming weeks: > > 22-28 June 2003 -> Variable types ( scalars, arrays and hashes ) > 29 June to 5 July 2003 -> Using modules > 6 - 19 July 2003 -> regex's (this is usually a hot topic, hence two weeks) > > If you think this is crazy, let me know - on the other hand, if you would like > to suggest something else - let's here about it. Great! I'm having a hard time, right now, to get modules to function at all. The literature I've perused so far, hasn't helped much. So, from an audience point of view, I'm very keen .. to the point of suggesting that the "Using Modules" topic be popped to the top of the list. I just hope that this doesn't turn out too much of a burden for the folks that can contribute papers. ciao -- any woman would like to be faithful. The difficulty is finding a man to be faithful to. Marlene Dietrich \|/ (o o) --------------ooO0-(_)-0Ooo---------------------------------------------- G. Contrafatto - School of Life and Environmental Science University of Natal Durban - Ph. +270312603336 ########################################################################## Visit Darwin at http://contra.biology.und.ac.za From nick at cleaton.net Mon Jun 2 04:20:03 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - UPDATE In-Reply-To: <1054545405.13460.9.camel@contra.biology.und.ac.za> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> Message-ID: <20030602092003.GB272@lt1.cleaton.net> On Mon, Jun 02, 2003 at 11:16:45AM +0200, Dr Giancarlo Contrafatto wrote: > > I'm having a hard time, right now, to get modules to function at all. > The literature I've perused so far, hasn't helped much. Maybe we can help. What exactly is it that you're trying to do, and what are the problems you're seeing ? -- Nick From contrafa at biology.und.ac.za Mon Jun 2 05:21:51 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - UPDATE In-Reply-To: <20030602092003.GB272@lt1.cleaton.net> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> <20030602092003.GB272@lt1.cleaton.net> Message-ID: <1054549311.13615.38.camel@contra.biology.und.ac.za> On Mon, 2003-06-02 at 11:20, Nick Cleaton wrote: > On Mon, Jun 02, 2003 at 11:16:45AM +0200, Dr Giancarlo Contrafatto wrote: > > > > I'm having a hard time, right now, to get modules to function at all. > > The literature I've perused so far, hasn't helped much. > > Maybe we can help. > > What exactly is it that you're trying to do, and what are the problems > you're seeing ? Thanks Nick; well, none of the modules I've tried to "use", so far, functions. I have the feeling it is due to the PERL locale in my directory tree, although it is a default RH 8.0 installation. I don't actually have the code at hand (it's on my home machine) so, I can't give you an accurate transcript. The situation, though, arises within scripts. The debugger/compiler message is, usually, something to the effect that there is some item or other that cannot be loaded (seems to be different things for different modules) and then a list of *.pm found in @INC (i.e /usr/lib/perl/5.08/ and subdirectories). Needless to say, I've investigated the lines of the modules where this happens and I've tried to make the AWOL components available by moving them within the path. I guess, it is best if I retreive the code I was using for testing (and the messages), from my home machine, and post them here tomorrow morning. Thanks for the help. ciao -- any woman would like to be faithful. The difficulty is finding a man to be faithful to. Marlene Dietrich \|/ (o o) --------------ooO0-(_)-0Ooo---------------------------------------------- G. Contrafatto - School of Life and Environmental Science University of Natal Durban - Ph. +270312603336 ########################################################################## Visit Darwin at http://contra.biology.und.ac.za From spikeh at mweb.co.za Mon Jun 2 00:48:13 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Perl Source Code Formatter In-Reply-To: <200305311701.h4VH1IJ14601@mail.pm.org> Message-ID: <5.2.1.1.0.20030602073908.01db9490@pop3.mweb.co.za> In vi (or at least in vim) you can select visual mode v blockmark your code and then type an = sign - and it will do quite a good job of formatting the whole lot. To make it pretty in vi I would also suggest that you use (or put in your .vimrc file) :- set expandtab (makes tabs real spaces so it still looks cool in other editors) set sw=3 (sets the shift width) set ts =3 (sets the tab to 3 spaces) With the ts and sw set to the default the code goes of the side of the screen after a few nested ifs! Try set syntax=perl too. The perl syntax highlighting is not had for HTML etc. At 2003/05/31 07:00 PM, you wrote: >Send Za-pm mailing list submissions to > za-pm@mail.pm.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.pm.org/mailman/listinfo/za-pm >or, via email, send a message with subject or body 'help' to > za-pm-request@mail.pm.org > >You can reach the person managing the list at > za-pm-admin@mail.pm.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Za-pm digest..." > > >Today's Topics: > > 1. Re: books (Nico Coetzee) > 2. Perl Source Code Formatter (Rory Austin) > 3. Re: Perl Source Code Formatter (Nico Coetzee) > >--__--__-- > >Message: 1 >From: Nico Coetzee >Organization: ITFirms.co.za >To: za-pm@mail.pm.org >Subject: Re: [Za-pm] books >Date: Fri, 30 May 2003 19:33:25 +0200 > >I have never paid customs duty - even when the total value exceeded R1000 - >personally I don't knoe if it should be an automatic thing, or do the customs >trust you to fill in some form? I honestly don't know, and every person you >ask has a different story :-| > >Anyway - I read the the story on the two URL's, and I must say, I havn't >experienced anything like they describe. I order books - ussually from >Amazon.com - and within two to three weeks I get the postoffice note. I then >go pick up the books, and that's it. My average order is well in excess of >$40 ( or R400 ), so I really don't know... > >Weird how these import stuff works - but for me, it's still a mystery. > >On Friday 30 May 2003 08:03, Sean Carte wrote: > > On Thu, 2003-05-29 at 08:37, Spike wrote: > > > Also at a value of $4.50 there was no customs hassle (which can be a > > > problem with Amazon orders). > > > > Is it true that there is no customs duty on items that cost less than > > R400? > > > > and > > > > > > I assume that that includes shipping, and is worked out at the exchange > > rate applicable on the day that the item crosses paths with customs? > >-- >Nico Coetzee > >http://www.itfirms.co.za/ >http://za.pm.org/ >http://forums.databasejournal.com/ > >To the systems programmer, users and applications serve only to provide a >test load. > > >--__--__-- > >Message: 2 >Date: Sat, 31 May 2003 15:06:41 +0200 >To: za-pm@mail.pm.org >From: Rory Austin >Subject: [Za-pm] Perl Source Code Formatter > >Hi > >I'm looking for a tool to indent my code for me... 1000+ lines. Preferably >one that uses STDIN and STDOUT so I can easily integrate with an IDE. > >Can any of you recommend any? Or have you got a perl script to do it? > >Thanks, >Rory > > >--__--__-- > >Message: 3 >From: Nico Coetzee >Organization: ITFirms.co.za >To: za-pm@mail.pm.org >Subject: Re: [Za-pm] Perl Source Code Formatter >Date: Sat, 31 May 2003 17:55:23 +0200 > >http://search.cpan.org/author/SHANCOCK/Perl-Tidy-20021130/bin/perltidy > >On Saturday 31 May 2003 15:06, Rory Austin wrote: > > Hi > > > > I'm looking for a tool to indent my code for me... 1000+ lines. Preferably > > one that uses STDIN and STDOUT so I can easily integrate with an IDE. > > > > Can any of you recommend any? Or have you got a perl script to do it? > > > > Thanks, > > Rory > > > > _______________________________________________ > > Za-pm mailing list > > Za-pm@mail.pm.org > > http://mail.pm.org/mailman/listinfo/za-pm > >-- >Nico Coetzee > >http://www.itfirms.co.za/ >http://za.pm.org/ >http://forums.databasejournal.com/ > >To the systems programmer, users and applications serve only to provide a >test load. > > > >--__--__-- > >_______________________________________________ >Za-pm mailing list >Za-pm@mail.pm.org >http://mail.pm.org/mailman/listinfo/za-pm > > >End of Za-pm Digest Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030602/14f678f4/attachment.htm From nico at itfirms.co.za Mon Jun 2 12:32:37 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE In-Reply-To: <002e01c328e0$fce24b20$a802000a@realm.co.za> References: <200306010951.11391.nico@itfirms.co.za> <20030602075720.GS17622@qualica.com> <002e01c328e0$fce24b20$a802000a@realm.co.za> Message-ID: <200306021932.37327.nico@itfirms.co.za> On Monday 02 June 2003 10:28, Dallas G wrote: > Hi > > I would love to do this.. > being a perl newbie i think these would be a great way to learn. > I would like to write some tuts, this way forces me to learn > > is this going to be meetings, or tuts on the website? Initially, tuts on the web, but I am thinking of some meetings. Unfortunately most of us is from Gauteng, which might let some others feel left out, but I have many plans up me sleeve :) Cheers > > Regards > Dallas Goldswain > > ----- Original Message ----- > From: "Oskar Pearson" > To: "Nico Coetzee" > Cc: > Sent: Monday, June 02, 2003 9:57 AM > Subject: Re: [Za-pm] UPDATE > > > Hi > > On Sun, Jun 01, 2003 at 09:51:11AM +0200, Nico Coetzee wrote: > > Hi there list members :) > > > > I have updated the home page, http://za.pm.org/ with some news. Please > > have a > > > look, and discuss in here. > > > > With this latest - perhaps crazy - idea of mine, I would like to propose > > the > > > following focus areas for the comming weeks: > > > > 22-28 June 2003 -> Variable types ( scalars, arrays and hashes ) > > 29 June to 5 July 2003 -> Using modules > > 6 - 19 July 2003 -> regex's (this is usually a hot topic, hence two > > weeks) > > > > If you think this is crazy, let me know - on the other hand, if you would > > like > > > to suggest something else - let's here about it. > > I like this idea; perhaps it needs to be nailed down > more (ie more detail), or should someone be given responsibility to > create a set of posts that discusses things, like 1 per day or something? > > I'll volunteer for doing some of this if you want. > > I wonder if I should do something like this for the glug-tech > list. hmm. > > Oskar > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm > > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From nico at itfirms.co.za Mon Jun 2 12:37:38 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - UPDATE In-Reply-To: <1054545405.13460.9.camel@contra.biology.und.ac.za> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> Message-ID: <200306021937.38709.nico@itfirms.co.za> I will try to post articles to the web as soon as they come in - so as soon as we have a Modules Tut - you will be the x'th person to know :) Cheers On Monday 02 June 2003 11:16, Dr Giancarlo Contrafatto wrote: >--- snip --- > > Great! > > I'm having a hard time, right now, to get modules to function at all. > The literature I've perused so far, hasn't helped much. So, from an > audience point of view, I'm very keen .. to the point of suggesting that > the "Using Modules" topic be popped to the top of the list. I just hope > that this doesn't turn out too much of a burden for the folks that can > contribute papers. > > ciao -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From nico at itfirms.co.za Mon Jun 2 12:46:23 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE In-Reply-To: <00a101c328e3$068061b0$a802000a@realm.co.za> References: <200306010951.11391.nico@itfirms.co.za> <20030602083909.GY17622@qualica.com> <00a101c328e3$068061b0$a802000a@realm.co.za> Message-ID: <200306021946.23701.nico@itfirms.co.za> On Monday 02 June 2003 10:43, Dallas G wrote: > thanks > > I see there are hundreds of extra libs for perl, CPAN > are they all optional? > can you recomend which are good to have for generic web page/db interaction It depends really on what OS you are now - I assume as with Linux, most other Perl installs will include some fundamental basic modules like DBI (for databases ) and CGI ( optional, but usefull ). TIP: If I want to do something, I go to http://search.cpan.org/ and search for a keyword that summrises my problem - 9/10 times a module pop's up. I then enter the command: $ perl -e 'use The::Module' and then I see if I have it, and if it works. It will work if the command returns no output and gives you a shell promt again. Sample: I want to convert between various mathematical Units. In CPAN, I did a search for 'unit convert' ( http://search.cpan.org/search?m=all&q=unit+convert&s=11 ) and found a Module called Math::Units ( http://search.cpan.org/author/KENFOX/Math-Units-1.2/Units.pm ) - and as you can see, does basically what I want. the shell test: $ perl -e 'use Math::Units' Can't locate Math/Units.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at -e line 1. BEGIN failed--compilation aborted at -e line 1. So, now I have to install it. Cheers > > thanks > Dallas > > ----- Original Message ----- > From: "Oskar Pearson" > To: "Dallas G" > Cc: > Sent: Monday, June 02, 2003 10:39 AM > Subject: Re: [Za-pm] UPDATE > > > Hi > > > I would love to do this.. > > being a perl newbie i think these would be a great way to learn. > > I would like to write some tuts, this way forces me to learn > > More as an aside than anything else. > > http://www.linux.org.za/whole-perl-tutorial.txt > > I learned my first perl from that - quite cool. > > Oskar > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From fuzzylogik at webmail.co.za Mon Jun 2 14:17:27 2003 From: fuzzylogik at webmail.co.za (Dallas G) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] UPDATE References: <200306010951.11391.nico@itfirms.co.za> <20030602083909.GY17622@qualica.com> <00a101c328e3$068061b0$a802000a@realm.co.za> <200306021946.23701.nico@itfirms.co.za> Message-ID: <002701c3293b$9baa89c0$0100a8c0@fuzzbox> Thanks will give it a try when the time arises ----- Original Message ----- From: "Nico Coetzee" To: "Dallas G" ; "Oskar Pearson" Cc: Sent: Monday, June 02, 2003 7:46 PM Subject: Re: [Za-pm] UPDATE On Monday 02 June 2003 10:43, Dallas G wrote: > thanks > > I see there are hundreds of extra libs for perl, CPAN > are they all optional? > can you recomend which are good to have for generic web page/db interaction It depends really on what OS you are now - I assume as with Linux, most other Perl installs will include some fundamental basic modules like DBI (for databases ) and CGI ( optional, but usefull ). TIP: If I want to do something, I go to http://search.cpan.org/ and search for a keyword that summrises my problem - 9/10 times a module pop's up. I then enter the command: $ perl -e 'use The::Module' and then I see if I have it, and if it works. It will work if the command returns no output and gives you a shell promt again. Sample: I want to convert between various mathematical Units. In CPAN, I did a search for 'unit convert' ( http://search.cpan.org/search?m=all&q=unit+convert&s=11 ) and found a Module called Math::Units ( http://search.cpan.org/author/KENFOX/Math-Units-1.2/Units.pm ) - and as you can see, does basically what I want. the shell test: $ perl -e 'use Math::Units' Can't locate Math/Units.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at -e line 1. BEGIN failed--compilation aborted at -e line 1. So, now I have to install it. Cheers > > thanks > Dallas > > ----- Original Message ----- > From: "Oskar Pearson" > To: "Dallas G" > Cc: > Sent: Monday, June 02, 2003 10:39 AM > Subject: Re: [Za-pm] UPDATE > > > Hi > > > I would love to do this.. > > being a perl newbie i think these would be a great way to learn. > > I would like to write some tuts, this way forces me to learn > > More as an aside than anything else. > > http://www.linux.org.za/whole-perl-tutorial.txt > > I learned my first perl from that - quite cool. > > Oskar > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm > _______________________________________________ > Za-pm mailing list > Za-pm@mail.pm.org > http://mail.pm.org/mailman/listinfo/za-pm -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From nick at cleaton.net Tue Jun 3 03:26:01 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - UPDATE In-Reply-To: <1054549311.13615.38.camel@contra.biology.und.ac.za> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> <20030602092003.GB272@lt1.cleaton.net> <1054549311.13615.38.camel@contra.biology.und.ac.za> Message-ID: <20030603082601.GC270@lt1.cleaton.net> On Mon, Jun 02, 2003 at 12:21:51PM +0200, Dr Giancarlo Contrafatto wrote: > > well, none of the modules I've tried to "use", so far, functions. I have > the feeling it is due to the PERL locale in my directory tree, although > it is a default RH 8.0 installation. > > I don't actually have the code at hand (it's on my home machine) so, I > can't give you an accurate transcript. The situation, though, arises > within scripts. The debugger/compiler message is, usually, something to > the effect that there is some item or other that cannot be loaded (seems > to be different things for different modules) and then a list of *.pm > found in @INC (i.e /usr/lib/perl/5.08/ and subdirectories). Needless to > say, I've investigated the lines of the modules where this happens and > I've tried to make the AWOL components available by moving them within > the path. > > I guess, it is best if I retreive the code I was using for testing (and > the messages), from my home machine, and post them here tomorrow > morning. Yes please. Also, if you're getting messages along the lines of: Can't locate Foo.pm in @INC (@INC contains: /usr/local/lib/perl/ ..... then it'd help if you could track down the missing Foo.pm (or whatever it is in your case) by running a shell command like: locate '*/Foo.pm' -- Nick From contrafa at biology.und.ac.za Tue Jun 3 07:06:05 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - perl modules In-Reply-To: <20030603082601.GC270@lt1.cleaton.net> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> <20030602092003.GB272@lt1.cleaton.net> <1054549311.13615.38.camel@contra.biology.und.ac.za> <20030603082601.GC270@lt1.cleaton.net> Message-ID: <1054641965.2655.33.camel@contra.biology.und.ac.za> On Tue, 2003-06-03 at 10:26, Nick Cleaton wrote: > > > > I guess, it is best if I retreive the code I was using for testing (and > > the messages), from my home machine, and post them here tomorrow > > morning. > > Yes please. Also, if you're getting messages along the lines of: > > Can't locate Foo.pm in @INC (@INC contains: /usr/local/lib/perl/ ..... > > then it'd help if you could track down the missing Foo.pm (or whatever > it is in your case) by running a shell command like: > > locate '*/Foo.pm' Yep, done that and downloaded the offending modules. This fixed a few errors but not all. By the look of the first compiler message below, I must now go and hunt for more modules. In this first example, I'm just testing the Tk.pm with the simple "Hello World" script that comes with the pod. The code, which I forgot to send to my office machine, starts off as it should (I think): #! /usr/perl -w use Tk; use strict; ... and then the code to write "Hello World", which is not crucial to have right now. The message is as follows: Can't locate loadable object for module Event in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/5.8.0/Tk/Event.pm line 23 Compilation failed in require at /usr/lib/perl5/5.8.0/Tk.pm line 13. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.0/Tk.pm line 13. Compilation failed in require at hello line 2. BEGIN failed--compilation aborted at hello line 2. Can't locate Event/all_watchers.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 ..... same list here ...... /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/5.8.0/Tk/Event.pm line 50. ...propagated at /usr/lib/perl5/5.8.0/Tk/Event.pm line 51. END failed--call queue aborted at hello line 2. Now, Events.pm is one of the modules I was missing (the preceding error message pointed to it), so I downloaded it and "just placed" it in the path. In restrospect, this may have been a dumb way of doing it because, by the look of it, there are plenty dependencies to be taken care of. The way I see it (check my reasoning here), the whole sequence fails straight away (line 2 of the hello script) where Tk is used. It fails because Tk depends on Events.pm which, in turn, depends on all_watchers.pm but also needs some unspecified "loadable object" which I haven't been able to identify by checking around line 23 of Events.pm. So, maybe I should have "made" Tk when I downloaded it but, it came without makefile and the pod didn't mention anything about installations. The other module I'm busy testing is Imager.pm and it does pretty much the same thing as Tk though, in this case, the offending dependency happens in DynaLoader: Can't locate loadable object for module Imager in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 ..... same list here ...... /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 153 BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.0/Imager.pm line 153. Compilation failed in require at thumb_01 line 6. BEGIN failed--compilation aborted at thumb_01 line 6. And that's all I can say for the time being. Thanks ciao -- we should distrust any enterprise that requires new clothes. Henry David Thoreau \|/ (o o) --------------ooO0-(_)-0Ooo---------------------------------------------- G. Contrafatto - School of Life and Environmental Science University of Natal Durban - Ph. +270312603336 ########################################################################## Visit Darwin at http://contra.biology.und.ac.za From nick at cleaton.net Tue Jun 3 08:05:57 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - perl modules In-Reply-To: <1054641965.2655.33.camel@contra.biology.und.ac.za> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> <20030602092003.GB272@lt1.cleaton.net> <1054549311.13615.38.camel@contra.biology.und.ac.za> <20030603082601.GC270@lt1.cleaton.net> <1054641965.2655.33.camel@contra.biology.und.ac.za> Message-ID: <20030603130556.GG270@lt1.cleaton.net> On Tue, Jun 03, 2003 at 02:06:05PM +0200, Dr Giancarlo Contrafatto wrote: > > > > locate '*/Foo.pm' > > Yep, done that and downloaded the offending modules. This fixed a few > errors but not all. By the look of the first compiler message below, I > must now go and hunt for more modules. > > In this first example, I'm just testing the Tk.pm with the simple "Hello > World" script that comes with the pod. The code, which I forgot to send > to my office machine, starts off as it should (I think): > > #! /usr/perl -w > > use Tk; > use strict; > ... and then the code to write "Hello World", which is not crucial to > have right now. > > The message is as follows: > > Can't locate loadable object for module Event in @INC (@INC contains: [SNIP] > > Now, Events.pm is one of the modules I was missing (the preceding error > message pointed to it), so I downloaded it and "just placed" it in the > path. In restrospect, this may have been a dumb way of doing it because, > by the look of it, there are plenty dependencies to be taken care of. > The way I see it (check my reasoning here), the whole sequence fails > straight away (line 2 of the hello script) where Tk is used. It fails > because Tk depends on Events.pm which, in turn, depends on > all_watchers.pm but also needs some unspecified "loadable object" which > I haven't been able to identify by checking around line 23 of Events.pm. > So, maybe I should have "made" Tk when I downloaded it but, it came > without makefile and the pod didn't mention anything about > installations. Yes, that's it exactly, you need to get the module source and build it rather than downloading individual .pm files. The 'loadable object' refers to the part of the Tk module that's written in C rather than Perl. That needs to be compiled on your system to make a loadable object which the Perl interpreter can load up when loads Tk.pm There are several different ways to get Tk.pm properly installed: via your package manager ======================== I don't know Redhat that well, but I expect there's a graphical package manager that lets you fetch and install RPMs to get extra software. Since you're using the perl that came with Redhat, you may find that you have the option of installing the Tk module as an RPM. via CPAN ======== CPAN (the Comprehensive Perl Archive Network, http://www.cpan.org/) is an online repository of perl modules. Perl comes with a module (CPAN.pm) which you can use to fetch, build and install stuff from CPAN. To get Tk from CPAN, you might do something like this at the shell prompt: perl -MCPAN -eshell CPAN.pm will ask you some questions if this is the first time you've used it, and then give you a prompt like: cpan> At this prompt, enter the command: install Tk ... and it will download the Tk module from a CPAN mirror and build and install it for you. from source =========== If you don't want to use CPAN.pm, you can download the latest version of the Tk module source and build it yourself. The source is available for download at: http://ftp.rucus.ru.ac.za/pub/perl/CPAN/modules/by-module/Tk/Tk800.023.tar.gz After fetching that file: gzip -dc Tk800.023.tar.gz cd Tk800.023 perl Makefile.PL make make test make install ... which is what pretty much what CPAN.pm does for you. With this approach you may find that the installation fails because Tk needs some other module to be installed first, which you then need to fetch and install before trying the Tk installation again. One of the nicest things about CPAN.pm is that it will sort out these dependencies by itself, fetching and installing any other modules that Tk needs before trying to install Tk. -- Nick From contrafa at biology.und.ac.za Tue Jun 3 09:12:25 2003 From: contrafa at biology.und.ac.za (Dr Giancarlo Contrafatto) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Re: Za-pm digest, Vol 1 #21 - perl modules In-Reply-To: <20030603130556.GG270@lt1.cleaton.net> References: <200306011701.h51H1LX03717@mail.pm.org> <1054545405.13460.9.camel@contra.biology.und.ac.za> <20030602092003.GB272@lt1.cleaton.net> <1054549311.13615.38.camel@contra.biology.und.ac.za> <20030603082601.GC270@lt1.cleaton.net> <1054641965.2655.3 <20030603130556.GG270@lt1.cleaton.net> Message-ID: <1054649545.2655.72.camel@contra.biology.und.ac.za> On Tue, 2003-06-03 at 15:05, Nick Cleaton wrote: [SNIP] > > all_watchers.pm but also needs some unspecified "loadable object" which > > I haven't been able to identify by checking around line 23 of Events.pm. > > So, maybe I should have "made" Tk when I downloaded it but, it came > > without makefile and the pod didn't mention anything about > > installations. > > Yes, that's it exactly, you need to get the module source and build it > rather than downloading individual .pm files. Right! Maybe this issue should make up the beginning of a za-pm Q&A for novices, called "The dumb things beginners do when they don't ask around or 101 frustrating reasons for giving up programming" :-) [SNIP] > To get Tk from CPAN, you might do something like this at the shell > prompt: > > perl -MCPAN -eshell Er ... yea ... right, I've discovered it just yesterday while looking for bits and pieces of Tk on my machine. (Dumb thing number two: check ALL the documentation before starting). > If you don't want to use CPAN.pm, you can download the latest version of > the Tk module source and build it yourself. The source is available for > download at: > > http://ftp.rucus.ru.ac.za/pub/perl/CPAN/modules/by-module/Tk/Tk800.023.tar.gz Exactly what I was looking for but, I couldn't find it on the perldoc.org CPAN. So, dumb thing number three (make sure that what you download is exactly what you were looking for). Thanks again. ciao -- we should distrust any enterprise that requires new clothes. Henry David Thoreau \|/ (o o) --------------ooO0-(_)-0Ooo---------------------------------------------- G. Contrafatto - School of Life and Environmental Science University of Natal Durban - Ph. +270312603336 ########################################################################## Visit Darwin at http://contra.biology.und.ac.za From bartho at cae.co.za Wed Jun 4 01:33:33 2003 From: bartho at cae.co.za (Bartho Saaiman) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script Message-ID: <3EDD92BC.7070706@cae.co.za> I want to filter a log file that I currently have to manipulate manually. So I was thinking to myself that this would be nice if I could do this with Perl. If it would be easier in bash, suggestions would also be welcome. So here is the scenario: Output of log file (sms.log): [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters to 271234567891 [Fri May 23 18:16:02 SAST 2003] SMS "Some User" sent 150 characters to 271234567891 [Sat May 24 12:51:37 SAST 2003] SMS "Some User" sent 151 characters to 271234567891 [Mon May 26 15:16:00 SAST 2003] SMS Some User sent 142 characters to 271234567891 So the first problem is that the user (Some User) detail is logged in three different ways. I am also only interested in the email addres as I can use this to do accountting with. I am currentl using bash like this: [bartho@hercules bartho]$ cat smslog |grep "May"| grep "2003" |awk \ '{print $8, $9, $10}' user@domain.co.za sent 47 "Some User" Some User Now this is where my problem starts. I probably need to use regular expressions to feed it the month and the domain. The year I could probably use in a regex too, but this doesn't change to often. Then I ned to send this to a clean file only containing the emails that this originated from. I do not need to sort them as unique since I have to add them up, similar to 'wc -l' I know this is a lot of questions, but any pointers would be appreciated. -- # Bartho Saaiman # Stellenbosch Automotive Engineering # Tel :: 27 21 882 8820 x 215 # Cell :: 27 82 551 2703 # Email :: bartho @ cae.co.za # GnuPG Key is available at http://www.cae.co.za/people/bartho From oskar at qualica.com Wed Jun 4 06:17:18 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <3EDD92BC.7070706@cae.co.za> References: <3EDD92BC.7070706@cae.co.za> Message-ID: <20030604111718.GT32094@qualica.com> On Wed, Jun 04, 2003 at 08:33:33AM +0200, Bartho Saaiman wrote: > I want to filter a log file that I currently have to manipulate > manually. So I was thinking to myself that this would be nice if I could > do this with Perl. If it would be easier in bash, suggestions would also > be welcome. So here is the scenario: > > Output of log file (sms.log): > > [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 > characters to 271234567891 > [Fri May 23 18:16:02 SAST 2003] SMS "Some User" > sent 150 characters to 271234567891 > [Sat May 24 12:51:37 SAST 2003] SMS "Some User" > sent 151 characters to 271234567891 > [Mon May 26 15:16:00 SAST 2003] SMS Some User sent > 142 characters to 271234567891 > > > So the first problem is that the user (Some User) detail is logged in > three different ways. I am also only interested in the email addres as I > can use this to do accountting with. I am currentl using bash like this: > > [bartho@hercules bartho]$ cat smslog |grep "May"| grep "2003" |awk \ > '{print $8, $9, $10}' > user@domain.co.za sent 47 > "Some User" > Some User > > Now this is where my problem starts. I probably need to use regular > expressions to feed it the month and the domain. The year I could > probably use in a regex too, but this doesn't change to often. Then I > ned to send this to a clean file only containing the emails that this > originated from. I do not need to sort them as unique since I have to > add them up, similar to 'wc -l' I'm not sure I understand the output you want, I'm afraid. I'm also assuming that the log lines above weren't meant to be wrapped? (ie they were one long line) how about something like this: oskar@core1:~$ cat t.txt [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters to 271234567891 [Fri May 23 18:16:02 SAST 2003] SMS "Some User" sent 150 characters to 271234567891 [Sat May 24 12:51:37 SAST 2003] SMS "Some User" sent 151 characters to 271234567891 [Mon May 26 15:16:00 SAST 2003] SMS Some User sent 142 characters to 271234567891 oskar@core1:~$ cat t.pl while () { my ($date, $address, $characters, $cell) = $_ =~ /^\[(.+)\] SMS +(.+) sent (.+) characters to (.+)$/; print "$cell no, $characters chars (from $address at $date)\n"; } oskar@core1:~$ perl t.pl < t.txt 271234567891 no, 43 chars (from user@domain.co.za at Fri May 23 11:02:12 SAST 2003) 271234567891 no, 150 chars (from "Some User" at Fri May 23 18:16:02 SAST 2003) 271234567891 no, 151 chars (from "Some User" at Sat May 24 12:51:37 SAST 2003) 271234567891 no, 142 chars (from Some User at Mon May 26 15:16:00 SAST 2003) oskar@core1:~$ Oskar -- Oskar Pearson Qualica Technologies (Pty) Ltd web: http://www.qualica.com/ From spikeh at mweb.co.za Wed Jun 4 06:40:05 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604111718.GT32094@qualica.com> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> Message-ID: <5.2.1.1.0.20030604133625.01ee6ec8@pop3.mweb.co.za> or you could try:- [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters to 271234567891 while (<>} { chomp; /[(.+)]\s+SMS\s+(+.)\s+sent\s+(\d+)\s+characters to\s+(\d+)/ || next; # \s+ just in case the spaces are tabs or multiple spaces # contents of () are in $1,$2,etc $date = $1; $e-mail = $2; $char_count = $3; $phone = $4; $total_char_count += $char_count; # do something } Regex are cool - you can do everything twenty different ways! At 2003/06/04 01:17 PM, Oskar Pearson wrote: >On Wed, Jun 04, 2003 at 08:33:33AM +0200, Bartho Saaiman wrote: > > I want to filter a log file that I currently have to manipulate > > manually. So I was thinking to myself that this would be nice if I could > > do this with Perl. If it would be easier in bash, suggestions would also > > be welcome. So here is the scenario: > > > > Output of log file (sms.log): > > > > [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 > > characters to 271234567891 > > [Fri May 23 18:16:02 SAST 2003] SMS "Some User" > > sent 150 characters to 271234567891 > > [Sat May 24 12:51:37 SAST 2003] SMS "Some User" > > sent 151 characters to 271234567891 > > [Mon May 26 15:16:00 SAST 2003] SMS Some User sent > > 142 characters to 271234567891 > > > > > > So the first problem is that the user (Some User) detail is logged in > > three different ways. I am also only interested in the email addres as I > > can use this to do accountting with. I am currentl using bash like this: > > > > [bartho@hercules bartho]$ cat smslog |grep "May"| grep "2003" |awk \ > > '{print $8, $9, $10}' > > user@domain.co.za sent 47 > > "Some User" > > Some User > > > > Now this is where my problem starts. I probably need to use regular > > expressions to feed it the month and the domain. The year I could > > probably use in a regex too, but this doesn't change to often. Then I > > ned to send this to a clean file only containing the emails that this > > originated from. I do not need to sort them as unique since I have to > > add them up, similar to 'wc -l' > >I'm not sure I understand the output you want, I'm afraid. I'm also >assuming that the log lines above weren't meant to be wrapped? (ie >they were one long line) > >how about something like this: > >oskar@core1:~$ cat t.txt >[Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters >to 271234567891 >[Fri May 23 18:16:02 SAST 2003] SMS "Some User" sent >150 characters to 271234567891 >[Sat May 24 12:51:37 SAST 2003] SMS "Some User" sent >151 characters to 271234567891 >[Mon May 26 15:16:00 SAST 2003] SMS Some User sent >142 characters to 271234567891 >oskar@core1:~$ cat t.pl >while () { > my ($date, $address, $characters, $cell) = > $_ =~ /^\[(.+)\] SMS +(.+) sent (.+) characters to (.+)$/; > print "$cell no, $characters chars (from $address at $date)\n"; >} >oskar@core1:~$ perl t.pl < t.txt >271234567891 no, 43 chars (from user@domain.co.za at Fri May 23 11:02:12 >SAST 2003) >271234567891 no, 150 chars (from "Some User" at Fri >May 23 18:16:02 SAST 2003) >271234567891 no, 151 chars (from "Some User" at Sat >May 24 12:51:37 SAST 2003) >271234567891 no, 142 chars (from Some User at Mon May >26 15:16:00 SAST 2003) >oskar@core1:~$ > >Oskar >-- >Oskar Pearson >Qualica Technologies (Pty) Ltd >web: http://www.qualica.com/ >_______________________________________________ >Za-pm mailing list >Za-pm@mail.pm.org >http://mail.pm.org/mailman/listinfo/za-pm Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030604/65c3ba19/attachment.htm From nick at cleaton.net Wed Jun 4 06:50:36 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <3EDD92BC.7070706@cae.co.za> References: <3EDD92BC.7070706@cae.co.za> Message-ID: <20030604115036.GE269@lt1.cleaton.net> On Wed, Jun 04, 2003 at 08:33:33AM +0200, Bartho Saaiman wrote: > I want to filter a log file that I currently have to manipulate > manually. So I was thinking to myself that this would be nice if I could > do this with Perl. If it would be easier in bash, suggestions would also > be welcome. So here is the scenario: > > Output of log file (sms.log): > > [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 > characters to 271234567891 > [Fri May 23 18:16:02 SAST 2003] SMS "Some User" > sent 150 characters to 271234567891 > [Sat May 24 12:51:37 SAST 2003] SMS "Some User" > sent 151 characters to 271234567891 > [Mon May 26 15:16:00 SAST 2003] SMS Some User sent > 142 characters to 271234567891 > > > So the first problem is that the user (Some User) detail is logged in > three different ways. I am also only interested in the email addres as I > can use this to do accountting with. I am currentl using bash like this: > > [bartho@hercules bartho]$ cat smslog |grep "May"| grep "2003" |awk \ > '{print $8, $9, $10}' > user@domain.co.za sent 47 > "Some User" > Some User > > Now this is where my problem starts. I probably need to use regular > expressions to feed it the month and the domain. The year I could > probably use in a regex too, but this doesn't change to often. Then I > ned to send this to a clean file only containing the emails that this > originated from. I do not need to sort them as unique since I have to > add them up, similar to 'wc -l' As I understand it, you want just the email addresses, so if the input is "Some User" then you want just the user@domain.co.za part. Is that right ? Here's the script I might write to solve that problem: #!/usr/bin/perl -w use strict; =head1 NAME get_email.pl - quick script to extract email addresses from SMS log =head1 SYNOPSIS get_email.pl [smslog ...] =head1 DESCRIPTION Parses SMS log files to extract a list of user email addresses, and prints them to STDOUT one per line. =cut # A regular expression to match a reasonable looking email address my $email = qr#[\w\-\.]+\@[\w\-\.]+#; while(<>) { chomp; unless ( /^\[([\w\s:]+)\] SMS\s+(.+?)\s+sent \d+ characters to \d+\s*$/ ) { warn "Can't parse log line [$_]\n"; next; } my ($date, $addr) = ($1, $2); # We're only interested in May next unless $date =~ / May /; if ( $addr =~ /<($email)>$/ or $addr =~ /^($email)$/ ) { print "$1\n"; } else { warn "Can't parse address [$addr] at log line [$_]\n"; } } -- Nick From oskar at qualica.com Wed Jun 4 06:52:17 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <5.2.1.1.0.20030604133625.01ee6ec8@pop3.mweb.co.za> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604133625.01ee6ec8@pop3.mweb.co.za> Message-ID: <20030604115217.GA21585@qualica.com> On Wed, Jun 04, 2003 at 01:40:05PM +0200, Spike wrote: > or you could try:- > > > [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters > to 271234567891 > > while (<>} > { > chomp; > > /[(.+)]\s+SMS\s+(+.)\s+sent\s+(\d+)\s+characters to\s+(\d+)/ || > next; > > # \s+ just in case the spaces are tabs or multiple spaces > # contents of () are in $1,$2,etc > > $date = $1; > $e-mail = $2; > $char_count = $3; > $phone = $4; > > $total_char_count += $char_count; > > # do something > > } > > Regex are cool - you can do everything twenty different ways! Or just do it on the command line like awk. :) oskar@core1:~$ perl -p -e '$_ =~ /^\[(.+)\] SMS +(.+) sent (.+) characters to (.+)$/; $_ = "$1 $2 $3 $4\n";' < t.txt Fri May 23 11:02:12 SAST 2003 user@domain.co.za 43 271234567891 Fri May 23 18:16:02 SAST 2003 "Some User" 150 271234567891 Sat May 24 12:51:37 SAST 2003 "Some User" 151 271234567891 Mon May 26 15:16:00 SAST 2003 Some User 142 271234567891 oskar@core1:~$ Oskar -- Oskar Pearson Qualica Technologies (Pty) Ltd web: http://www.qualica.com/ From spikeh at mweb.co.za Wed Jun 4 07:16:08 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604115036.GE269@lt1.cleaton.net> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> Message-ID: <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> I see your use of perldoc entries - nice. Is there a simple way to force perldoc to launch if the user enters ./myscriptwithdoc --help? something like: if ($ARGV[0] =~ /help/i) { system("perldoc $0"); } >=head1 NAME > >get_email.pl - quick script to extract email addresses from SMS log > >=head1 SYNOPSIS > > get_email.pl [smslog ...] > >=head1 DESCRIPTION > >Parses SMS log files to extract a list of user email addresses, and >prints them to STDOUT one per line. > >=cut > ># A regular expression to match a reasonable looking email address >my $email = qr#[\w\-\.]+\@[\w\-\.]+#; > >while(<>) { > chomp; > > unless ( /^\[([\w\s:]+)\] SMS\s+(.+?)\s+sent \d+ characters to > \d+\s*$/ ) { > warn "Can't parse log line [$_]\n"; > next; > } > my ($date, $addr) = ($1, $2); > > # We're only interested in May > next unless $date =~ / May /; > > if ( $addr =~ /<($email)>$/ or $addr =~ /^($email)$/ ) { > print "$1\n"; > } > else { > warn "Can't parse address [$addr] at log line [$_]\n"; > } >} > > > >-- >Nick >_______________________________________________ >Za-pm mailing list >Za-pm@mail.pm.org >http://mail.pm.org/mailman/listinfo/za-pm Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030604/6b4fccfb/attachment.htm From bartho at cae.co.za Wed Jun 4 07:46:13 2003 From: bartho at cae.co.za (Bartho Saaiman) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604111718.GT32094@qualica.com> References: <3EDD92BC.7070706@cae.co.za> <20030604111718.GT32094@qualica.com> Message-ID: <3EDDEA15.30003@cae.co.za> Hi Oskar. Your assumption that the log lines are wrapped is correct. If I use my previous bash script I get the same as with this perl script that you suggest. I need to filter this file in such a manner that it only displays the email of the person that the mail originated from and obviously there might be more than one email address. If I use awk '{print $8, $9, $10}' it returns the values for column 8, 9 and 10 from the input file. What I want is to only have the emails (user1@domain.co.za, user2@domain.co.za etc.) to be filtered to an output file which I could use for accountting purposes. Does this make more sense?? :) Oskar Pearson wrote: > On Wed, Jun 04, 2003 at 08:33:33AM +0200, Bartho Saaiman wrote: > > I'm not sure I understand the output you want, I'm afraid. I'm also > assuming that the log lines above weren't meant to be wrapped? (ie > they were one long line) > > how about something like this: > > oskar@core1:~$ cat t.txt > [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters to 271234567891 > [Fri May 23 18:16:02 SAST 2003] SMS "Some User" sent 150 characters to 271234567891 > [Sat May 24 12:51:37 SAST 2003] SMS "Some User" sent 151 characters to 271234567891 > [Mon May 26 15:16:00 SAST 2003] SMS Some User sent 142 characters to 271234567891 > oskar@core1:~$ cat t.pl > while () { > my ($date, $address, $characters, $cell) = > $_ =~ /^\[(.+)\] SMS +(.+) sent (.+) characters to (.+)$/; > print "$cell no, $characters chars (from $address at $date)\n"; > } > oskar@core1:~$ perl t.pl < t.txt > 271234567891 no, 43 chars (from user@domain.co.za at Fri May 23 11:02:12 SAST 2003) > 271234567891 no, 150 chars (from "Some User" at Fri May 23 18:16:02 SAST 2003) > 271234567891 no, 151 chars (from "Some User" at Sat May 24 12:51:37 SAST 2003) > 271234567891 no, 142 chars (from Some User at Mon May 26 15:16:00 SAST 2003) > oskar@core1:~$ > http://mail.pm.org/mailman/listinfo/za-pm -- # Bartho Saaiman # Stellenbosch Automotive Engineering # Tel :: 27 21 882 8820 x 215 # Cell :: 27 82 551 2703 # Email :: bartho @ cae.co.za # GnuPG Key is available at http://www.cae.co.za/people/bartho From oskar at qualica.com Wed Jun 4 08:05:50 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <3EDDEA15.30003@cae.co.za> References: <3EDD92BC.7070706@cae.co.za> <20030604111718.GT32094@qualica.com> <3EDDEA15.30003@cae.co.za> Message-ID: <20030604130550.GD21974@qualica.com> Hi > Your assumption that the log lines are wrapped is correct. If I use my > previous bash script I get the same as with this perl script that you > suggest. > > I need to filter this file in such a manner that it only displays the > email of the person that the mail originated from and obviously there > might be more than one email address. If I use > awk '{print $8, $9, $10}' it returns the values for column 8, 9 and 10 > from the input file. What I want is to only have the emails > (user1@domain.co.za, user2@domain.co.za etc.) to be filtered to an > output file which I could use for accountting purposes. > > Does this make more sense?? So you basically want to discard the date and length and stuff, and simply get the addresses? while () { my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+)/; print "email_address: $email_address\n"; } The above means: assign to variable $email_address any sequence of strings that has the format of: one or more [non-space or non-< characters] followed by an @sign, followed by one or more [non-space and non-> characters] oskar@core1:~$ perl t.pl < t.txt email_address: user@domain.co.za email_address: user@domain.co.za email_address: user@domain.co.za email_address: user@domain.co.za oskar@core1:~$ Oskar From nick at cleaton.net Wed Jun 4 08:21:45 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> Message-ID: <20030604132145.GG269@lt1.cleaton.net> On Wed, Jun 04, 2003 at 02:16:08PM +0200, Spike wrote: > I see your use of perldoc entries - nice. > Is there a simple way to force perldoc to launch if the user enters > ./myscriptwithdoc --help? > > something like: > > if ($ARGV[0] =~ /help/i) > { > system("perldoc $0"); > } Interesting idea, I've never thought of doing that. Something a bit stricter than /help/ might be a good idea, otherwise someone could get in a mess trying to use it on a log file with 'help' in its name. Using exec() instead of system() will prevent the script from continuing after running perldoc, and giving an error message when it can't open a file called --help. So maybe: if ( $ARGV[0] eq '--help' ) { exec('perldoc', $0); } -- Nick From nick at cleaton.net Wed Jun 4 08:27:38 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604130550.GD21974@qualica.com> References: <3EDD92BC.7070706@cae.co.za> <20030604111718.GT32094@qualica.com> <3EDDEA15.30003@cae.co.za> <20030604130550.GD21974@qualica.com> Message-ID: <20030604132738.GH269@lt1.cleaton.net> On Wed, Jun 04, 2003 at 03:05:50PM +0200, Oskar Pearson wrote: > > So you basically want to discard the date and length and stuff, > and simply get the addresses? > > while () { > my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+)/; > print "email_address: $email_address\n"; > } That will go wrong on pathalogical cases like this: [Sat May 24 12:51:37 SAST 2003] SMS "Mr Br@@i Dude" sent 151 characters to 271234567891 -- Nick From oskar at qualica.com Wed Jun 4 08:32:35 2003 From: oskar at qualica.com (Oskar Pearson) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604132738.GH269@lt1.cleaton.net> References: <3EDD92BC.7070706@cae.co.za> <20030604111718.GT32094@qualica.com> <3EDDEA15.30003@cae.co.za> <20030604130550.GD21974@qualica.com> <20030604132738.GH269@lt1.cleaton.net> Message-ID: <20030604133235.GE21974@qualica.com> H > > while () { > > my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+)/; > > print "email_address: $email_address\n"; > > } > > That will go wrong on pathalogical cases like this: > > [Sat May 24 12:51:37 SAST 2003] SMS "Mr Br@@i Dude" sent 151 characters to 271234567891 > > -- > Nick Agreed; ta. My original script grabbed the email into another variable and then re-parsed it, which would have been more reliable, but I was going for "interesting regex" factor :) How about something like this; it anchors on the end-of-line to stop people doing something wierd like the following: [Sat May 24 12:51:37 SAST 2003] SMS "another@user sent 151 characters to 123123123" sent 151 characters to 271234567891 my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+) sent [0-9]+ characters to [0-9]+$/; I'm assuming the email will always be in the form "text name they supply" , never "something", but I guess that's a resonable assumption? Oskar -- Oskar Pearson Qualica Technologies (Pty) Ltd web: http://www.qualica.com/ From scarte at pan.uzulu.ac.za Wed Jun 4 08:34:56 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:58 2004 Subject: perldoc (was: Re: [Za-pm] Script) In-Reply-To: <20030604132145.GG269@lt1.cleaton.net> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> Message-ID: <1054733696.1936.111.camel@seanc.uznet.uz> On Wed, 2003-06-04 at 15:21, Nick Cleaton wrote: > On Wed, Jun 04, 2003 at 02:16:08PM +0200, Spike wrote: > > I see your use of perldoc entries - nice. > > Is there a simple way to force perldoc to launch if the user enters > > ./myscriptwithdoc --help? ... > if ( $ARGV[0] eq '--help' ) { > exec('perldoc', $0); > } That really is amazingly clever! I'm surprised that it I haven't seen this before. It's going to be a regular feature of any perl scripts that I write from now on. Thank you! -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony." From bartho at cae.co.za Wed Jun 4 08:54:22 2003 From: bartho at cae.co.za (Bartho Saaiman) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604132738.GH269@lt1.cleaton.net> References: <3EDD92BC.7070706@cae.co.za> <20030604111718.GT32094@qualica.com> <3EDDEA15.30003@cae.co.za> <20030604130550.GD21974@qualica.com> <20030604132738.GH269@lt1.cleaton.net> Message-ID: <3EDDFA0E.3000509@cae.co.za> You got to love the power of the Internet :) This works more than less for me for now, and I understand exactly why this might brake, so I will be careful. I am also playing with Oskar's one liner, which is not pure perl anymore so suggestions for improvement is welcome. Note that it might apper wrapped: [bartho@bartho]# perl -p -e '$_ =~ /^\[(.+)\] SMS .*\<(.+)\> \ sent (.+) characters to (.+)$/; $_ = "$1 $2 $3 $4\n";' < \ smslog |grep May|grep 2003 |awk '{if ($7=="bartho@cae.co.za") \ {user=user+1; print $7 " " user}}' bartho@cae.co.za 1 bartho@cae.co.za 2 bartho@cae.co.za 3 bartho@cae.co.za 4 bartho@cae.co.za 5 bartho@cae.co.za 6 bartho@cae.co.za 7 bartho@cae.co.za 8 bartho@cae.co.za 9 bartho@cae.co.za 10 Nick Cleaton wrote: > On Wed, Jun 04, 2003 at 03:05:50PM +0200, Oskar Pearson wrote: > >>So you basically want to discard the date and length and stuff, >>and simply get the addresses? >> >>while () { >> my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+)/; >> print "email_address: $email_address\n"; >>} > > > That will go wrong on pathalogical cases like this: > > [Sat May 24 12:51:37 SAST 2003] SMS "Mr Br@@i Dude" sent 151 characters to 271234567891 > > -- > Nick -- # Bartho Saaiman # Stellenbosch Automotive Engineering # Tel :: 27 21 882 8820 x 215 # Cell :: 27 82 551 2703 # Email :: bartho @ cae.co.za # GnuPG Key is available at http://www.cae.co.za/people/bartho From nick at cleaton.net Wed Jun 4 09:35:27 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <20030604133235.GE21974@qualica.com> References: <3EDD92BC.7070706@cae.co.za> <20030604111718.GT32094@qualica.com> <3EDDEA15.30003@cae.co.za> <20030604130550.GD21974@qualica.com> <20030604132738.GH269@lt1.cleaton.net> <20030604133235.GE21974@qualica.com> Message-ID: <20030604143527.GI269@lt1.cleaton.net> On Wed, Jun 04, 2003 at 03:32:35PM +0200, Oskar Pearson wrote: > > How about something like this; it anchors on the end-of-line to > stop people doing something wierd like the following: > [Sat May 24 12:51:37 SAST 2003] SMS "another@user sent 151 characters to 123123123" sent 151 characters to 271234567891 > > my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+) sent [0-9]+ characters to [0-9]+$/; > > I'm assuming the email will always be in the form "text name they supply" , > never "something", but I guess that's a resonable assumption? Yes, that'll work under that assumption. The trouble is that if the assumption turns out to be wrong it will fail silently, and the problem may not be noticed. Outputting a warning in that case might be more useful. my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+) sent [0-9]+ characters to [0-9]+$/; defined $email_address or warn "can't find address in line [$_]"; -- Nick From nico at itfirms.co.za Wed Jun 4 13:16:03 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <3EDD92BC.7070706@cae.co.za> References: <3EDD92BC.7070706@cae.co.za> Message-ID: <200306042016.04076.nico@itfirms.co.za> On Wednesday 04 June 2003 08:33, Bartho Saaiman wrote: > I want to filter a log file that I currently have to manipulate > manually. So I was thinking to myself that this would be nice if I could > do this with Perl. If it would be easier in bash, suggestions would also > be welcome. So here is the scenario: > > Output of log file (sms.log): > > [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 > characters to 271234567891 > [Fri May 23 18:16:02 SAST 2003] SMS "Some User" > sent 150 characters to 271234567891 > [Sat May 24 12:51:37 SAST 2003] SMS "Some User" > sent 151 characters to 271234567891 > [Mon May 26 15:16:00 SAST 2003] SMS Some User sent > 142 characters to 271234567891 > > > So the first problem is that the user (Some User) detail is logged in > three different ways. I am also only interested in the email addres as I > can use this to do accountting with. I am currentl using bash like this: > Just some notes of my own - it was probably mentioned in some of the other mails, but I might have mist it. We assume you have various forms of the name, but one particular e-mail. When ever you use regular expressions or other means, remember to first convert all ASCII text to the same case (or at least ignore case). What we can also do, is just use th first instance of the real name, and ignore the rest ( if we want a name ). Also remember to do away with all punctuations. Given the above example, here is a simple script: Sample Data: [Fri May 23 11:02:12 SAST 2003] SMS user@domain.co.za sent 43 characters to 271234567891 [Fri May 23 18:16:02 SAST 2003] SMS "Some User" sent 150 characters to 271234567891 [Sat May 24 12:51:37 SAST 2003] SMS "Some User" sent 151 characters to 271234567891 [Mon May 26 15:16:00 SAST 2003] SMS Soe User sent 142 characters to 271234567891 [Sat May 24 12:51:37 SAST 2003] SMS "Another User" sent 151 characters to 271234567891 [Fri May 23 18:16:02 SAST 2003] SMS sent 150 characters to 271234567891 Sample Run: $ cat test.txt | perl test.pl unknown = 150 Another User = 151 Some User = 486 NOTE: You should be aware that the data in a hash is not sorted - there is a way to do it, so just shout if you need it. Also note, that although the last instance of "Some User", the actual name is misspelled, it will still take only the first name it finds for that e-mail. For e-mails that have NO known name, we simply use 'unknown', but they will still be uniquely grouped, as we matched per e-mail. Cheers > [bartho@hercules bartho]$ cat smslog |grep "May"| grep "2003" |awk \ > '{print $8, $9, $10}' > user@domain.co.za sent 47 > "Some User" > Some User > > Now this is where my problem starts. I probably need to use regular > expressions to feed it the month and the domain. The year I could > probably use in a regex too, but this doesn't change to often. Then I > ned to send this to a clean file only containing the emails that this > originated from. I do not need to sort them as unique since I have to > add them up, similar to 'wc -l' > > I know this is a lot of questions, but any pointers would be appreciated. -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From dirkvanderwalt at webmail.co.za Wed Jun 4 13:31:33 2003 From: dirkvanderwalt at webmail.co.za (DIRK KONRAD) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] For Mandrake Users Message-ID: <200306041831.h54IVY6k010368@mailgate.mailbox.co.za> Hi All, This is for all the Mandrake users to try out, if you are bored. A 1/2 finished utility to ease the setup of workstations. Currently supporting Domain and LDAP authentication (and configuring of LDAP & Samba-LDAP servers). This is my first attempt @ Perl/TK and Perl for that matter. After I've got Mandrake to authenticate against NetWare 6 's LDAP earlier this year, I thought, why not make it more user friendly and at the same time, give Perl a try. This then, is the result so far. As for the site – it is not fully working yet, the centre is in the making. http://www.meraka.org.za (see Linux and Authentication + Downloads) Dirk _______________________________________________________________________ LOOK GOOD, FEEL GOOD - WWW.HEALTHIEST.CO.ZA Cool Connection, Cool Price, Internet Access for R59 monthly @ WebMail http://www.webmail.co.za/dialup/ From spikeh at mweb.co.za Thu Jun 5 00:55:21 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <200306042016.04076.nico@itfirms.co.za> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> Message-ID: <5.2.1.1.0.20030605075315.0cbe4440@pop3.mweb.co.za> Just bear in mind that an underscore is considered a word caracture by a regex but a dot or dash os not. many mail systems allow dots in the username spike.hodge@inode.co.za At 2003/06/04 08:16 PM, Nico Coetzee wrote: > # clear the username of non ASCII characters > $user =~ s/^\W+//; > $user =~ s/\W+$//; Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030605/12f1e6e8/attachment.htm From bartho at cae.co.za Thu Jun 5 01:36:17 2003 From: bartho at cae.co.za (Bartho Saaiman) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <200306042016.04076.nico@itfirms.co.za> References: <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> Message-ID: <3EDEE4E1.3010301@cae.co.za> Hi Nico I have cut some of your reply to make sure that this mail does not get to long. About your assumption: I have various forms of the name and might have more than one particuliar email. At this stage I am not really interested in a name, more in the email address. If I use your script in its current form, it seems to be adding the total for characters sent. What I want to establish is adding up the number of emails sent. Where can I find more on hash, as I can not seem to find anything on the use of this. Maybe it is time for coffee :) Nico Coetzee wrote: > On Wednesday 04 June 2003 08:33, Bartho Saaiman wrote: > > Just some notes of my own - it was probably mentioned in some of the other > mails, but I might have mist it. > > We assume you have various forms of the name, but one particular e-mail. When > ever you use regular expressions or other means, remember to first convert > all ASCII text to the same case (or at least ignore case). What we can also > do, is just use th first instance of the real name, and ignore the rest ( if > we want a name ). Also remember to do away with all punctuations. > > Given the above example, here is a simple script: > Sample Run: > [Mon May 26 15:16:00 SAST 2003] SMS Soe User sent 142 > characters to 271234567891 > [Sat May 24 12:51:37 SAST 2003] SMS "Another User" sent > 151 characters to 271234567891 > [Fri May 23 18:16:02 SAST 2003] SMS sent 150 characters > to 271234567891 > > $ cat test.txt | perl test.pl > unknown = 150 > Another User = 151 > Some User = 486 > > > NOTE: You should be aware that the data in a hash is not sorted - there is a > way to do it, so just shout if you need it. Also note, that although the last > instance of "Some User", the actual name is misspelled, it will still take > only the first name it finds for that e-mail. For e-mails that have NO known > name, we simply use 'unknown', but they will still be uniquely grouped, as we > matched per e-mail. > > Cheers -- # Bartho Saaiman # Stellenbosch Automotive Engineering # Tel :: 27 21 882 8820 x 215 # Cell :: 27 82 551 2703 # Email :: bartho @ cae.co.za # GnuPG Key is available at http://www.cae.co.za/people/bartho From scarte at pan.uzulu.ac.za Thu Jun 5 01:47:11 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Script In-Reply-To: <3EDEE4E1.3010301@cae.co.za> References: <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> <3EDEE4E1.3010301@cae.co.za> Message-ID: <1054795631.16362.29.camel@seanc.uznet.uz> On Thu, 2003-06-05 at 08:36, Bartho Saaiman wrote: > Where can I find more on hash, as I can not seem to find anything on the > use of this. Maybe it is time for coffee :) There's no time for coffee! Try perldoc perldata and . Chapter 4 of the Camel is a good place to start, or end, or go back to repeatedly until it suddenly starts to make sense. -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "...well, that's a pipe of a different color." -- Tuttle From spikeh at mweb.co.za Thu Jun 5 02:32:37 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Hashes In-Reply-To: <1054795631.16362.29.camel@seanc.uznet.uz> References: <3EDEE4E1.3010301@cae.co.za> <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> <3EDEE4E1.3010301@cae.co.za> Message-ID: <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> At 2003/06/05 08:47 AM, Sean Carte wrote: >Chapter 4 of the Camel is a good place to start, or end, or go back to >repeatedly until it suddenly starts to make sense. Oh yes! I know exactly what you mean. All the books seem to get too deep into hashes too quick. My advice is to just start trying to put something in a hash and get it out again - it will make sense eventual - I promise. In one of the reference books is says something like "There is no technical limit to the number of dimensions in a hash array [hashes of hashes of hashes ...] But most human programers stop at 3" Start simple:- %hash = ( car => 1, wife => 2, dog => 4, kids => 2 ) print "$hash{car}\n"; # 1 expected print "$hash{wife}\n; # 2 expected $hash{dog} = 6; print "$hash{dog}\n"; # 6 expected $hash{dog} ++; print "$hash{dog}\n"; # 7 expected foreach $key (keys %hash) { print "The value for key $key is $hash{$key}\n"; } # The value for key car is 1 # The value for key wife is 2 # etc. expected Remember that keys are unique so you can use a hash as a unique command. Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030605/2a2a2a41/attachment.htm From bartho at cae.co.za Thu Jun 5 02:56:45 2003 From: bartho at cae.co.za (Bartho Saaiman) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Graphs with Perl Message-ID: <3EDEF7BD.80202@cae.co.za> Since I am on a go now, I decided to add some more.. I have attached the code to the latest 'version' of my script and some output. Any comments... [bartho@poseidon tmp]$ perl bartho.pl < bartho bartho@cae.co.za: 9,833 byte(s) - 27 72 341-8626: 5,553 **************************** - bartho: 3,156 **************** - 27 82 928-5537: 324 * - 27 84 500-0674: 303 * - 27 82 575-4054: 237 * - 27 83 273-6289: 77 - bgmilne: 50 - 27 84 575-4054: 43 - 27 82 472-2231: 39 - 27 82 390-6668: 37 - michaelc: 14 -- # Bartho Saaiman # Stellenbosch Automotive Engineering # Tel :: 27 21 882 8820 x 215 # Cell :: 27 82 551 2703 # Email :: bartho @ cae.co.za # GnuPG Key is available at http://www.cae.co.za/people/bartho -------------- next part -------------- #!/usr/bin/perl use strict; #use diagnostics; my %total; sub commify { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; } sub pad { my ($text) = @_; my $padding = ' '; return substr($padding, 0, -length($text)); } sub padphone { my ($number) = @_; return "$1 $2 $3-$4" if ($number =~ /^(\d{2})(\d{2})(\d{3})(\d{4})$/); return $number; } sub graph { my ($size, $total) = @_; my $bar = '**************************************************'; return substr($bar, 0, int($size * length($bar) / $total)); } while (<>) { my ($from, $bytes, $to) = /^.*? SMS .*?(\w+\@[.\w]+).*? sent (.*?) characters to (.*?)$/; if ($from and $bytes and $to) { $to = padphone($to); $total{$from}{total} += $bytes; # totals $total{$from}{to}{$to} += $bytes; # sub-totals } else { warn 'Ignoring: ' . $_ . "\n"; } } print "\n"; foreach my $from (keys %total) { my $total = $total{$from}{total}; print $from . ': ' . commify($total) . ' byte(s)' . "\n"; foreach my $to ( sort { $total{$from}{to}{$b} <=> $total{$from}{to}{$a} } keys %{$total{$from}{to}} ) { my $bytes = commify($total{$from}{to}{$to}); print '- ' . $to . ': ' . pad($to) . ' ' . pad($bytes) . $bytes . ' ' . graph($total{$from}{to}{$to}, $total) . "\n"; } print "\n"; } From scarte at pan.uzulu.ac.za Thu Jun 5 03:57:05 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Graphs with Perl In-Reply-To: <3EDEF7BD.80202@cae.co.za> References: <3EDEF7BD.80202@cae.co.za> Message-ID: <1054803425.16362.36.camel@seanc.uznet.uz> On Thu, 2003-06-05 at 09:56, Bartho Saaiman wrote: > Since I am on a go now, I decided to add some more.. > > I have attached the code to the latest 'version' of my script and some > output. Any comments... Have a look at the GDGraph module. I haven't done anything more than play with the samples, but it seemed quite capable. -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "La di di, one two three, it's Eric the half a bee..." From nick at cleaton.net Thu Jun 5 04:44:15 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Graphs with Perl In-Reply-To: <3EDEF7BD.80202@cae.co.za> References: <3EDEF7BD.80202@cae.co.za> Message-ID: <20030605094415.GB262@lt1.cleaton.net> On Thu, Jun 05, 2003 at 09:56:45AM +0200, Bartho Saaiman wrote: > Since I am on a go now, I decided to add some more.. > > I have attached the code to the latest 'version' of my script and some > output. Any comments... [SNIP] > sub graph > { > my ($size, $total) = @_; > my $bar = '**************************************************'; > > return substr($bar, 0, int($size * length($bar) / $total)); > } I would rather use the 'x' operator than substr there: sub graph { my ($size, $total) = @_; return '*' x (50 * $size/$total); } But that's just personal preference. There's nothing wrong with your way. > while (<>) > { > my ($from, $bytes, $to) = /^.*? SMS .*?(\w+\@[.\w]+).*? sent (.*?) characters to (.*?)$/; As Spike mentioned earlier, you sometimes get '.' and '-' in email usernames. '-' is also allowed in hostnames, so how about: my ($from, $bytes, $to) = /^.*? SMS .*?([.\w-]+\@[.\w-]+).*? sent (.*?) characters to (.*?)$/; [SNIP] > else > { > warn 'Ignoring: ' . $_ . "\n"; > } Good, I like warnings :) If you do get a '.' or a '-' or something else in an email address, at least you'll find out about it. -- Nick From theunis at ixpress.co.za Thu Jun 5 05:24:30 2003 From: theunis at ixpress.co.za (Theunis De Klerk) Date: Mon Aug 2 21:39:58 2004 Subject: [Za-pm] Hashes In-Reply-To: <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> References: <3EDEE4E1.3010301@cae.co.za> <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> <3EDEE4E1.3010301@cae.co.za> <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> Message-ID: <1054808681.9191.16.camel@ixp-theunis> Hi Everyone, I'm a newbie, especially to Perl.So could someone please explain what hashes are and what they are used for. From what i see they are sort of like multi demensional arrays . Is that right? Muchly appreciated!!! Theunis On Thu, 2003-06-05 at 09:32, Spike wrote: > At 2003/06/05 08:47 AM, Sean Carte wrote: > >Chapter 4 of the Camel is a good place to start, or end, or go back to > >repeatedly until it suddenly starts to make sense. > > Oh yes! I know exactly what you mean. All the books seem to get too deep > into hashes too quick. > > My advice is to just start trying to put something in a hash and get it out > again - it will make sense eventual - I promise. > > In one of the reference books is says something like "There is no technical > limit to the number of dimensions in a hash array [hashes of hashes of > hashes ...] But most human programers stop at 3" > > Start simple:- > > %hash = ( > car => 1, > wife => 2, > dog => 4, > kids => 2 > ) > > print "$hash{car}\n"; # 1 expected > print "$hash{wife}\n; # 2 expected > > $hash{dog} = 6; > > print "$hash{dog}\n"; # 6 expected > > $hash{dog} ++; > > print "$hash{dog}\n"; # 7 expected > > foreach $key (keys %hash) > { > print "The value for key $key is $hash{$key}\n"; > } > > # The value for key car is 1 > # The value for key wife is 2 > # etc. expected > > > Remember that keys are unique so you can use a hash as a unique command. > > > > > > > > Spike Hodge > > UNIX Programmer > M-Web Technology > 021 596 8496 > 082 901 5265 > > Click here and make M-Web your homepage > http://homepage.mweb.co.za From spikeh at mweb.co.za Thu Jun 5 07:14:31 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Hashes In-Reply-To: <1054808681.9191.16.camel@ixp-theunis> References: <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> <3EDEE4E1.3010301@cae.co.za> <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> <3EDEE4E1.3010301@cae.co.za> <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> Message-ID: <5.2.1.1.0.20030605140728.023865c8@pop3.mweb.co.za> Spot on! they used to be called associative arrays. A hash is an array of key and value pairs. The values must be scalars however they may be references to arrays or to hashes. (references are scalars). They have a few qwerks; like you can't predict what order they will return values in like and array so you often need to sort on the keys a (or values) as you retrieve them. Keys must be unique. And they screw with your mind when you create hashes of arrays of hashes etc :-) But they are powerful and you can build a whole database in one hash. You can even bind it a file for permanence with various modules. At 2003/06/05 12:24 PM, Theunis De Klerk wrote: >Hi Everyone, > >I'm a newbie, especially to Perl.So could someone please explain what >hashes are and what they are used for. From what i see they are sort of >like multi demensional arrays . Is that right? Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030605/015bbfa6/attachment.htm From spikeh at mweb.co.za Thu Jun 5 07:15:37 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <1054733696.1936.111.camel@seanc.uznet.uz> References: <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> Message-ID: <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> Anybody got this to work yet? At 2003/06/04 03:34 PM, Sean Carte wrote: > > if ( $ARGV[0] eq '--help' ) { > > exec('perldoc', $0); > > } > >That really is amazingly clever! I'm surprised that it I haven't seen >this before. It's going to be a regular feature of any perl scripts that >I write from now on. Thank you! >-- >Regards >Sean Carte > >University of Zululand >Network Services Unit >Phone: 035 902 6081 >Fax: 035 902 6028 Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030605/c77848f5/attachment.htm From scarte at pan.uzulu.ac.za Thu Jun 5 07:40:52 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> References: <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> Message-ID: <1054816852.16129.75.camel@seanc.uznet.uz> On Thu, 2003-06-05 at 14:15, Spike wrote: > Anybody got this to work yet? > > > At 2003/06/04 03:34 PM, Sean Carte wrote: > > > if ( $ARGV[0] eq '--help' ) { > > > exec('perldoc', $0); > > > } What do you mean? I'm using it already. My scripts now look like this: #!/usr/bin/perl -w =head1 NAME test_script.pl =head1 SYNOPSIS blah =head1 DESCRIPTION This is a test =head1 DATE 20030605 =cut if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ) { exec('perldoc', $0); } use strict; print 'one, two, three ...', "\n"; exit 0; __END__ Calling them normally works: [seanc@seanc scripts]$ perl test_script.pl one, two, three ... and calling them with --test works too: [seanc@seanc scripts]$ perl test_script.pl --help TEST_SCRIPT(1) User Contributed Perl Documentation TEST_SCRIPT(1) NAME test_script.pl SYNOPSIS blah DESCRIPTION This is a test DATE 20030605 perl v5.8.0 2003?06?05 TEST_SCRIPT(1) /tmp/zcqzxjqbCN (END) Some of my scripts do a little more than that though, but you get the idea ... -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "La di di, one two three, it's Eric the half a bee..." From scarte at pan.uzulu.ac.za Thu Jun 5 07:54:12 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Hashes In-Reply-To: <5.2.1.1.0.20030605140728.023865c8@pop3.mweb.co.za> References: <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> <3EDEE4E1.3010301@cae.co.za> <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> <3EDEE4E1.3010301@cae.co.za> <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> <5.2.1.1.0.20030605140728.023865c8@pop3.mweb.co.za> Message-ID: <1054817652.16362.90.camel@seanc.uznet.uz> On Thu, 2003-06-05 at 14:14, Spike wrote: > And they screw with your > mind when you create hashes of arrays of hashes etc :-) > > But they are powerful and you can build a whole database in one hash. You > can even bind it a file for permanence with various modules. My first encounter with them involved a hash-based database, which used hashes of arrays and a DBM file for storage. After many days of frustration someone on a mailing list was kind enough to point out that you simply can't store references to an array to a file and hope to retrieve the contents later. You have to stringify the array first. I eventually landed up using the MLDBM module. I did learn a bit about hashes in the process, though it felt like I'd done permanent damage to my brain at the time. -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "La di di, one two three, it's Eric the half a bee..." From nick at cleaton.net Thu Jun 5 08:25:07 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <1054816852.16129.75.camel@seanc.uznet.uz> References: <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> Message-ID: <20030605132507.GK262@lt1.cleaton.net> On Thu, Jun 05, 2003 at 02:40:52PM +0200, Sean Carte wrote: > > if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ) { ^^^^^^^^^^^^ > exec('perldoc', $0); > } To prevent a warning if there are no arguments, right ? How about replacing those 3 lines with: exec 'perldoc', $0 if "@ARGV" eq '--help'; -- Nick From scarte at pan.uzulu.ac.za Thu Jun 5 08:30:14 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <20030605132507.GK262@lt1.cleaton.net> References: <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> Message-ID: <1054819814.16519.130.camel@seanc.uznet.uz> On Thu, 2003-06-05 at 15:25, Nick Cleaton wrote: > On Thu, Jun 05, 2003 at 02:40:52PM +0200, Sean Carte wrote: > > > > if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ) { > ^^^^^^^^^^^^ > > exec('perldoc', $0); > > } > > To prevent a warning if there are no arguments, right ? Exactly. > How about replacing those 3 lines with: > > exec 'perldoc', $0 if "@ARGV" eq '--help'; Nice. But I'll keep my warning prevention: exec 'perldoc', $0 if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ); -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "Always look on the bright side of life..." From nick at cleaton.net Thu Jun 5 09:08:58 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <1054819814.16519.130.camel@seanc.uznet.uz> References: <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> Message-ID: <20030605140858.GL262@lt1.cleaton.net> On Thu, Jun 05, 2003 at 03:30:14PM +0200, Sean Carte wrote: > > > > exec 'perldoc', $0 if "@ARGV" eq '--help'; > > Nice. But I'll keep my warning prevention: > > exec 'perldoc', $0 if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ); Try mine - no warning. -- Nick From spikeh at mweb.co.za Thu Jun 5 09:09:23 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <1054819814.16519.130.camel@seanc.uznet.uz> References: <20030605132507.GK262@lt1.cleaton.net> <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> Message-ID: <5.2.1.1.0.20030605160640.023b0428@pop3.mweb.co.za> I had some agro trying to do it with getopt (tried to interpret h e l p as args) so: getopts("hDd:f:t:", \%args) || exec('perldoc', $0); # perldoc if bad args (keys %args) || exec('perldoc', $0); #perldog if no args At 2003/06/05 03:30 PM, Sean Carte wrote: >On Thu, 2003-06-05 at 15:25, Nick Cleaton wrote: > > On Thu, Jun 05, 2003 at 02:40:52PM +0200, Sean Carte wrote: > > > > > > if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ) { > > ^^^^^^^^^^^^ > > > exec('perldoc', $0); > > > } > > > > To prevent a warning if there are no arguments, right ? > >Exactly. > > > How about replacing those 3 lines with: > > > > exec 'perldoc', $0 if "@ARGV" eq '--help'; > >Nice. But I'll keep my warning prevention: > >exec 'perldoc', $0 if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ); > >-- >Regards >Sean Carte > >University of Zululand >Network Services Unit >Phone: 035 902 6081 >Fax: 035 902 6028 > >"Always look on the bright side of life..." > >_______________________________________________ >Za-pm mailing list >Za-pm@mail.pm.org >http://mail.pm.org/mailman/listinfo/za-pm Spike Hodge UNIX Programmer M-Web Technology 021 596 8496 082 901 5265 Click here and make M-Web your homepage http://homepage.mweb.co.za -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030605/599ce848/attachment.htm From wernerm at ifusion.co.za Thu Jun 5 05:35:12 2003 From: wernerm at ifusion.co.za (Werner Moller) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Hashes Message-ID: <2E3F96E0A649D4118AFD00105AD507BF03F8A2BA@mail.ifusion.co.za> Read this doument set up by Robert Pepper, you might find a newer version on the net. It was my "Newbie Bible" and contains everything you need to know before getting into the deep end. Cheers, Werner PS: Read with IE - web archive single file -----Original Message----- From: Theunis De Klerk [mailto:theunis@ixpress.co.za] Sent: 05 June 2003 12:25 To: Spike Cc: Za-pm@mail.pm.org Subject: Re: [Za-pm] Hashes Hi Everyone, I'm a newbie, especially to Perl.So could someone please explain what hashes are and what they are used for. From what i see they are sort of like multi demensional arrays . Is that right? Muchly appreciated!!! Theunis On Thu, 2003-06-05 at 09:32, Spike wrote: > At 2003/06/05 08:47 AM, Sean Carte wrote: > >Chapter 4 of the Camel is a good place to start, or end, or go back to > >repeatedly until it suddenly starts to make sense. > > Oh yes! I know exactly what you mean. All the books seem to get too deep > into hashes too quick. > > My advice is to just start trying to put something in a hash and get it out > again - it will make sense eventual - I promise. > > In one of the reference books is says something like "There is no technical > limit to the number of dimensions in a hash array [hashes of hashes of > hashes ...] But most human programers stop at 3" > > Start simple:- > > %hash = ( > car => 1, > wife => 2, > dog => 4, > kids => 2 > ) > > print "$hash{car}\n"; # 1 expected > print "$hash{wife}\n; # 2 expected > > $hash{dog} = 6; > > print "$hash{dog}\n"; # 6 expected > > $hash{dog} ++; > > print "$hash{dog}\n"; # 7 expected > > foreach $key (keys %hash) > { > print "The value for key $key is $hash{$key}\n"; > } > > # The value for key car is 1 > # The value for key wife is 2 > # etc. expected > > > Remember that keys are unique so you can use a hash as a unique command. > > > > > > > > Spike Hodge > > UNIX Programmer > M-Web Technology > 021 596 8496 > 082 901 5265 > > Click here and make M-Web your homepage > http://homepage.mweb.co.za _______________________________________________ Za-pm mailing list Za-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/za-pm ############################################################################ ######### This e-mail message has been scanned for Viruses and Content and cleared by Ifusion's MailMarshal Gateway ############################################################################ ######### ##################################################################################### Note: This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. IFusion (PTY) Ltd and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. Thank You. ##################################################################################### -------------- next part -------------- A non-text attachment was scrubbed... Name: Robert's Perl Tutorial.mht Type: application/octet-stream Size: 330946 bytes Desc: not available Url : http://mail.pm.org/pipermail/za-pm/attachments/20030605/02f282c8/RobertsPerlTutorial.obj From nico at itfirms.co.za Thu Jun 5 12:32:32 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Script In-Reply-To: <3EDEE4E1.3010301@cae.co.za> References: <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> <3EDEE4E1.3010301@cae.co.za> Message-ID: <200306051932.32428.nico@itfirms.co.za> Ahh - I think I misunderstood the original question. In stead of: $usercounter{ $email } = $usercounter{ $email } + $counter; Just do: $usercounter{ $email }++; You also want to store the e-mails, rather then the names, so comment out: if ( not $usernames{ $email } ) { $usernames{ $email } = $user; } And change: if ( $name ) { print "$name = $count\n"; } else { print "unknown = $count\n"; } to read: print "$key=$count\n"; I will have something on variables in the comming article. If I get around to do it, it might be up by the end of the weekend. Cheers On Thursday 05 June 2003 08:36, Bartho Saaiman wrote: > Hi Nico > > I have cut some of your reply to make sure that this mail does not get > to long. > > About your assumption: I have various forms of the name and might have > more than one particuliar email. At this stage I am not really > interested in a name, more in the email address. If I use your script in > its current form, it seems to be adding the total for characters sent. > What I want to establish is adding up the number of emails sent. > > Where can I find more on hash, as I can not seem to find anything on the > use of this. Maybe it is time for coffee :) > > Nico Coetzee wrote: > > On Wednesday 04 June 2003 08:33, Bartho Saaiman wrote: > > > > Just some notes of my own - it was probably mentioned in some of the > > other mails, but I might have mist it. > > > > We assume you have various forms of the name, but one particular e-mail. > > When ever you use regular expressions or other means, remember to first > > convert all ASCII text to the same case (or at least ignore case). What > > we can also do, is just use th first instance of the real name, and > > ignore the rest ( if we want a name ). Also remember to do away with all > > punctuations. > > > > Given the above example, here is a simple script: > > Sample Run: > > [Mon May 26 15:16:00 SAST 2003] SMS Soe User sent > > 142 characters to 271234567891 > > [Sat May 24 12:51:37 SAST 2003] SMS "Another User" > > sent 151 characters to 271234567891 > > [Fri May 23 18:16:02 SAST 2003] SMS sent 150 > > characters to 271234567891 > > > > $ cat test.txt | perl test.pl > > unknown = 150 > > Another User = 151 > > Some User = 486 > > > > > > NOTE: You should be aware that the data in a hash is not sorted - there > > is a way to do it, so just shout if you need it. Also note, that although > > the last instance of "Some User", the actual name is misspelled, it will > > still take only the first name it finds for that e-mail. For e-mails that > > have NO known name, we simply use 'unknown', but they will still be > > uniquely grouped, as we matched per e-mail. > > > > Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From nico at itfirms.co.za Thu Jun 5 12:45:53 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Hashes In-Reply-To: <1054808681.9191.16.camel@ixp-theunis> References: <3EDEE4E1.3010301@cae.co.za> <5.2.1.1.0.20030605091515.01ee0d20@pop3.mweb.co.za> <1054808681.9191.16.camel@ixp-theunis> Message-ID: <200306051945.53411.nico@itfirms.co.za> On Thursday 05 June 2003 12:24, Theunis De Klerk wrote: > Hi Everyone, > > I'm a newbie, especially to Perl.So could someone please explain what > hashes are and what they are used for. From what i see they are sort of > like multi demensional arrays . Is that right? > > Muchly appreciated!!! > Theunis > Think of them as a big cupboard with many drawers. Each label on a drawer is an index, and if I open that drawer, I get the contents or value. Let's say our cupboard holds personal info of various people, like their e-mail address. The trick is that the index of a hash, must be the pipece of information that uniquely identifies that data. In our example, names can be duplicated - I know I share my name with some judge, and one or two other "Nico Coetzee's" out there. What uniquely identifies me, is my e-mail address, for example, nico@whereever.com. I will then use the e-mail as the index: $people{ "nico@whereever.com" } = "Nico Coetzee"; Because we now have an index, we can use that same index to store other bits of info in other cupboards, or hashes: $cellnr{ "nico@whereever.com" } = "000 000 0000"; Each time, we just add another person's data, by using his/her e-mail as the index. In the end, I can then get a list of everybodies cell nr's like this: foreach $key ( keys %people ) { $name = $people{ $key }; $cell = $cellnr{ $key }; print "$name => $cell\n"; } We are now looping through the hash, using the keys of the hash as a reference. With each loop, we use the value of the $key variable to extract the information from the hashes - this is optional, and you could combine it all in one row, but for me personally it sometimes makes more sense to do it this way ( logically ). Better look out for that articles :) Hope this helps somewhat Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From nico at itfirms.co.za Thu Jun 5 12:48:36 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Script In-Reply-To: <200306042016.04076.nico@itfirms.co.za> References: <3EDD92BC.7070706@cae.co.za> <200306042016.04076.nico@itfirms.co.za> Message-ID: <200306051948.36965.nico@itfirms.co.za> > > # clear the username of non ASCII characters > $user =~ s/^\W+//; > $user =~ s/\W+$//; > I actually need to correct myself - we are not removing NON ASCII characters, but removing non-aplhanumeric characters - big diff :) Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From nico at itfirms.co.za Thu Jun 5 14:16:45 2003 From: nico at itfirms.co.za (Nico Coetzee) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Hashes In-Reply-To: <2E3F96E0A649D4118AFD00105AD507BF03F8A2BA@mail.ifusion.co.za> References: <2E3F96E0A649D4118AFD00105AD507BF03F8A2BA@mail.ifusion.co.za> Message-ID: <200306052116.45196.nico@itfirms.co.za> On Thursday 05 June 2003 12:35, Werner Moller wrote: PLEASE don't send attachments - rather send me the file, and I will post it on the web page. Some of us are still using old slow connections :( Cheers -- Nico Coetzee http://www.itfirms.co.za/ http://za.pm.org/ http://forums.databasejournal.com/ To the systems programmer, users and applications serve only to provide a test load. From scarte at pan.uzulu.ac.za Fri Jun 6 00:38:57 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <20030605140858.GL262@lt1.cleaton.net> References: <20030604132145.GG269@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> <20030605140858.GL262@lt1.cleaton.net> Message-ID: <1054877938.16519.1106.camel@seanc.uznet.uz> On Thu, 2003-06-05 at 16:08, Nick Cleaton wrote: > On Thu, Jun 05, 2003 at 03:30:14PM +0200, Sean Carte wrote: > > > > > > exec 'perldoc', $0 if "@ARGV" eq '--help'; > > > > Nice. But I'll keep my warning prevention: > > > > exec 'perldoc', $0 if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ); > > Try mine - no warning. I still get a warning when I run the script: Use of uninitialized value in string eq at test_script.pl line 24. I think the critical difference is in my first line: #!/usr/bin/perl -w I always enable warnings (and use strict). -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "Good evening. Last week we learned how to saw a lady in half. This week we're going to learn how to saw a lady into three bits and dispose of the body ..." From Emmanuel.Asante at bhpbilliton.com Fri Jun 6 01:50:45 2003 From: Emmanuel.Asante at bhpbilliton.com (Asante, Emmanuel [ING-WBK]) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Hashes Message-ID: Robert Pepper's tutorial's url is as follows: http://www.netcat.co.uk/rob/perl/win32perltut.html Regards, Emmanuel -----Original Message----- From: Werner Moller [mailto:wernerm@ifusion.co.za] Sent: 05 June 2003 12:35 To: Theunis De Klerk; Za-pm@mail.pm.org Subject: RE: [Za-pm] Hashes Read this doument set up by Robert Pepper, you might find a newer version on the net. It was my "Newbie Bible" and contains everything you need to know before getting into the deep end. Cheers, Werner PS: Read with IE - web archive single file -----Original Message----- From: Theunis De Klerk [mailto:theunis@ixpress.co.za] Sent: 05 June 2003 12:25 To: Spike Cc: Za-pm@mail.pm.org Subject: Re: [Za-pm] Hashes Hi Everyone, I'm a newbie, especially to Perl.So could someone please explain what hashes are and what they are used for. From what i see they are sort of like multi demensional arrays . Is that right? Muchly appreciated!!! Theunis On Thu, 2003-06-05 at 09:32, Spike wrote: > At 2003/06/05 08:47 AM, Sean Carte wrote: > >Chapter 4 of the Camel is a good place to start, or end, or go back to > >repeatedly until it suddenly starts to make sense. > > Oh yes! I know exactly what you mean. All the books seem to get too deep > into hashes too quick. > > My advice is to just start trying to put something in a hash and get it out > again - it will make sense eventual - I promise. > > In one of the reference books is says something like "There is no technical > limit to the number of dimensions in a hash array [hashes of hashes of > hashes ...] But most human programers stop at 3" > > Start simple:- > > %hash = ( > car => 1, > wife => 2, > dog => 4, > kids => 2 > ) > > print "$hash{car}\n"; # 1 expected > print "$hash{wife}\n; # 2 expected > > $hash{dog} = 6; > > print "$hash{dog}\n"; # 6 expected > > $hash{dog} ++; > > print "$hash{dog}\n"; # 7 expected > > foreach $key (keys %hash) > { > print "The value for key $key is $hash{$key}\n"; > } > > # The value for key car is 1 > # The value for key wife is 2 > # etc. expected > > > Remember that keys are unique so you can use a hash as a unique command. > > > > > > > > Spike Hodge > > UNIX Programmer > M-Web Technology > 021 596 8496 > 082 901 5265 > > Click here and make M-Web your homepage > http://homepage.mweb.co.za _______________________________________________ Za-pm mailing list Za-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/za-pm ############################################################################ ######### This e-mail message has been scanned for Viruses and Content and cleared by Ifusion's MailMarshal Gateway ############################################################################ ######### ############################################################################ ######### Note: This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. IFusion (PTY) Ltd and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. Thank You. ############################################################################ ######### -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/za-pm/attachments/20030606/59a70470/attachment.htm From nick at cleaton.net Fri Jun 6 03:15:56 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <1054877938.16519.1106.camel@seanc.uznet.uz> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> <20030605140858.GL262@lt1.cleaton.net> <1054877938.16519.1106.camel@seanc.uznet.uz> Message-ID: <20030606081556.GB275@lt1.cleaton.net> On Fri, Jun 06, 2003 at 07:38:57AM +0200, Sean Carte wrote: > On Thu, 2003-06-05 at 16:08, Nick Cleaton wrote: > > On Thu, Jun 05, 2003 at 03:30:14PM +0200, Sean Carte wrote: > > > > > > > > exec 'perldoc', $0 if "@ARGV" eq '--help'; > > > > > > Nice. But I'll keep my warning prevention: > > > > > > exec 'perldoc', $0 if ( $ARGV[0] and ( $ARGV[0] eq '--help' ) ); > > > > Try mine - no warning. > > I still get a warning when I run the script: > > Use of uninitialized value in string eq at test_script.pl line 24. That's strange, I don't get that. > I think the critical difference is in my first line: > > #!/usr/bin/perl -w > > I always enable warnings (and use strict). I always do that too. I get no warnings with this test script: #!/usr/bin/perl -w use strict; =head1 NAME test - a test script =head1 SYNOPSIS foo =cut exec 'perldoc', $0 if "@ARGV" eq '--help'; print "hello, world ($])\n"; What perl version are you using ? Could you post your entire test script, and the shell command you're using to run it when you see a warning ? -- Nick From scarte at pan.uzulu.ac.za Fri Jun 6 03:55:21 2003 From: scarte at pan.uzulu.ac.za (Sean Carte) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <20030606081556.GB275@lt1.cleaton.net> References: <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> <20030605140858.GL262@lt1.cleaton.net> <1054877938.16519.1106.camel@seanc.uznet.uz> <20030606081556.GB275@lt1.cleaton.net> Message-ID: <1054889721.16362.1391.camel@seanc.uznet.uz> On Fri, 2003-06-06 at 10:15, Nick Cleaton wrote: > exec 'perldoc', $0 if "@ARGV" eq '--help'; Aha! I'm using $ARGV[0] where you're using @ARGV: > exec 'perldoc', $0 if $ARGV[0] eq '--help'; Your version uses the @ARGV array in a scalar context. Does this mean that @ARGV evaluates to $ARGV[0] before the comparison? If so, why is it different when specifying $ARGV[0]? There's something that I'm not understanding here. What's going on? (Has everybody else dozed off?) (In case it becomes relevant: $ perl -v This is perl, v5.8.0 built for i386-linux-thread-multi Using your script with "$ARGV[0]" substituted for "@ARGV": $ perl test_script.pl Use of uninitialized value in string at test_script.pl line 14. hello, world (5.008) ) -- Regards Sean Carte University of Zululand Network Services Unit Phone: 035 902 6081 Fax: 035 902 6028 "Ooooh fishy fishy fishy fish!" From nick at cleaton.net Fri Jun 6 04:41:45 2003 From: nick at cleaton.net (Nick Cleaton) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] Re: perldoc In-Reply-To: <1054889721.16362.1391.camel@seanc.uznet.uz> References: <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> <20030605140858.GL262@lt1.cleaton.net> <1054877938.16519.1106.camel@seanc.uznet.uz> <20030606081556.GB275@lt1.cleaton.net> <1054889721.16362.1391.camel@seanc.uznet.uz> Message-ID: <20030606094145.GC275@lt1.cleaton.net> On Fri, Jun 06, 2003 at 10:55:21AM +0200, Sean Carte wrote: > On Fri, 2003-06-06 at 10:15, Nick Cleaton wrote: > > exec 'perldoc', $0 if "@ARGV" eq '--help'; > > Aha! I'm using $ARGV[0] where you're using @ARGV: That'll do it :) > Your version uses the @ARGV array in a scalar context. Does this mean > that @ARGV evaluates to $ARGV[0] before the comparison? If so, why is it > different when specifying $ARGV[0]? It's not @ARGV in a scalar context, it's @ARGV interpolated into a doublequoted string. When you interpolate an array into a string, you get all the elements of the array joined with $", which is a space by default. For example: my @a = ('one', 'two'); print "@a\n"; # prints "one two" If the array is empty, you just get the empty string rather than undef. That's why there's no warning with this method. -- Nick From spikeh at mweb.co.za Fri Jun 6 04:49:33 2003 From: spikeh at mweb.co.za (Spike) Date: Mon Aug 2 21:39:59 2004 Subject: [Za-pm] oop In-Reply-To: <1054889721.16362.1391.camel@seanc.uznet.uz> References: <20030606081556.GB275@lt1.cleaton.net> <3EDD92BC.7070706@cae.co.za> <3EDD92BC.7070706@cae.co.za> <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> <20030605140858.GL262@lt1.cleaton.net> <1054877938.16519.1106.camel@seanc.uznet.uz> <20030606081556.GB275@lt1.cleaton.net> Message-ID: <5.2.1.1.0.20030606111644.0236d170@pop3.mweb.co.za> At 2003/06/06 10:55 AM, Sean Carte wrote: >Aha! I'm using $ARGV[0] where you're using @ARGV: I did that too :-( I have written a object orientated perl module called Mailsend.pl. It give a very simple interface to sendmail and allows you to send HTML formatted mail or plain or HTML and plain (multipart) and most importantly attachments. The attachments bit is what makes it really usefully - attaching a file in send mail is horrible and with this module you can write a simple perl script to allow you to send attachments from the command line if you want. It gives you control over things like the priority, from address, etc so would also be a good start to a spam machine. It's not huge and is a very simple example of oop; both how to use it and how to write one. The next step will be to replace sendmail with a built in SMTP engine ... You can perldoc it for instalation and usage stuff. #---------------------------------------------------------------- # Title : Mailsend.pm # Author : Spike spike@mweb.co.za # Date : 2003-03-04 # # Description # ----------- # This perl Module will provide a simple interface to Sendmail. # It must be copied to your library path. # To see a path list type: "perl -e 'print join("\n", @INC)'" # Various methods allow a mail to be sent to multiple recipients # in plain text, html or both, with or without multiple attachments. # The only obligatory methods Mailsend->new() and setTo("address"). # If the style is set to html and only a setPlain message body is # specified the plain text message will be set to html with a non-serif # font (more readable on screen) and any URLs will be expanded with # html tags to make them 'clickable'. # If the style is set to plain and only an html message body is set # an attempt to convert the html to plain text will be made. Note # that the results will probably be ugly. # If no style is set the setStyle will be defaulted to 'both' and # any necessary conversions made in accordance with the rules above. # A message with an attachment set with setAttach will have it's style # set to 'both'. Attachments are base64 encoded. # A message "priority can be set with setPriority. It can be set to any # value but values fro 1-5 are supported by most clients. "1" is highest, # "5" Lowest and "3" is Normal priority. # Code for subroutine 'old_encode_base64' taken from MIME::Base64 # by Gisle Aas . # # Examples # -------- # $msg1 = Mailsend->new(); # # $msg1->setTo('spike@mweb.com, recipient2@foo.com, ...'); # $msg1->setSubject("$subject"); # $msg1->setFrom('spike@mweb.co.za'); # $msg1->setStyle('plain'); or 'html' or 'both' # $msg1->setPlain("$plain_message_text") # #msg1->sethtml("$html_message_code") # $msg1->setMailprog('/path/to/sendmail'); # $msg1->setReplyto('sender@mweb.com'); # $msg1->setCc('cc_recipient1@inode.co.za, cc_recipient2@inode.co.za, ...'); # $msg1->setBcc('bcc_recipient1@inode.co.za, bcc_recipient2@inode.co.za, ...'); # $msg1->setAttach('/root/file1, /var/log/file2.txt, /home/me/file3, ...'); # $msg1->setPriority('1') # 1 high to 5 low. 3 normal. # # # Change Control # --------------- # Date: 2003-03-o4 # Author: Spike spike@mweb.co.za # Change: Initial version # package Mailsend; use File::Basename; use strict; sub send { my (%self, @attachments, $file, $basefilename, $encoded); my $self = shift; my ($die, $warn, $rv, $content_type, $message); unless (defined $self->{Mailprog}) { $warn .= "No mail program defined\nI shall try and use a default\n"; chomp($rv = `which sendmail`); if ($rv !~ /no sendmail/) { $self->{Mailprog} = $rv; $warn .= "I have set the Mailprog to $rv\n"; } else { $die .= "I can't find a suitable Mailprog ... quiting\n"; } } ($warn) && (print $warn); ($die) && (print $die) && (exit 0); ($self->{Attach}) && ($self->{Style} = "both"); ($self->{Style}) || ($self->{Style} = "both"); #-- plain only --# if ($self->{Style} =~ m/plain/i) { $content_type = "text/plain; charset=\"us=ascii\"\n\n"; #-- get some plain content if((defined $self->{Html}) && (! defined $self{Plain})) { $self->{Plain} = makeplain("$self->{Html}"); } #-- build and send a plain only $message = $self->{Plain}; } #-- html only --# if ($self->{Style} =~ m/html/i) { $content_type = 'text/html; charset="us=ascii"'; #-- get some html if ((defined $self->{Plain}) && (! defined $self->{Html})) { $self->{Html} = makehtml("$self->{Plain}"); } #-- build and send html only $message = $self->{Html}; } #-- both --# if ($self->{Style} =~ m/Both/i) { if ((defined $self->{Plain}) && (! defined $self->{Html})) { $self->{Html} = makehtml("$self->{Plain}"); } if((defined $self->{Html}) && (! defined $self->{Plain})) { $self->{Plain} = makeplain("$self->{Html}"); } $content_type = 'multipart/alternative;' . qq{boundary="BoundaryPoodle"}; $message = "\n--BoundaryPoodle\nContent-Type: text/plain; charset=\"us=ascii\"\n\n$self->{Plain}\n"; $message .= "\n--BoundaryPoodle\nContent-Type: text/html; charset=\"us=ascii\"\n\n$self->{Html}\n"; #$message = "\n--BoundaryPoodle\nContent-Type: text/plain; charset=\"us=ascii\"\nContent-Transfer-Encoding: 7bit\n\n$self->{Plain}\n"; #$message .= "\n--BoundaryPoodle\nContent-Type: text/html; charset=\"us=ascii\"\nContent-Transfer-Encoding: 7bit\n\n$self->{Html}\n"; $message .= "\n--BoundaryPoodle--\n"; } #-- attach--# if ($self->{Attach}) { my $debug = $self->{Attach}; @attachments = split(',',$self->{Attach}); $content_type = 'multipart/mixed; ' . qq{boundary="mmBoundaryPoodle"}; $content_type .= "\n\n--mmBoundaryPoodle\n"; $content_type .= 'Content-Type: multipart/alternative; ' . qq{boundary="BoundaryPoodle"\n}; foreach $file (@attachments) { chomp($file); $file =~ s/^\s+//g; $file =~ s/\s+$//g; $basefilename = basename($file); (-e "$file") || die(qq(I can't find file $file\n)); local($/) = undef; open(FILE, "$file") or die "$!"; $encoded = old_encode_base64(); $message .= "--mmBoundaryPoodle"; $message .= "\nContent-Type: application/octet-stream; name=\"$basefilename\""; $message .= "\nContent-Transfer-Encoding: base64"; $message .= "\nContent-Disposition: attachment; filename=\"$basefilename\""; $message .= "\n\n$encoded"; close FILE; } $message .= "--mmBoundaryPoodle--"; } my $full_message = qq{From: $self->{From}\n}; $full_message .= qq{To: $self->{To}\n}; ($self->{Replyto}) && ($full_message .= qq{Reply-To: $self->{Replyto}\n}); ($self->{Cc}) && ($full_message .= qq{Cc: $self->{Cc}\n}); ($self->{Bcc}) && ($full_message .= qq{Bcc: $self->{Bcc}\n}); ($self->{Subject}) && ($full_message .= qq{Subject: $self->{Subject}\n}); $full_message .= "Mime-Version: 1.0\n"; ($self->{Priority}) && ($full_message .= qq{X-Priority: $self->{Priority}\n}); $full_message .= "Content-Type: $content_type\n"; $full_message .= $message; open(SENDMAIL, "|$self->{Mailprog} -oi -t"); print SENDMAIL "$full_message"; close SENDMAIL; } # constructor # sub new { my $class = shift; my $self = {}; return bless $self, $class; } # methods # sub setStyle{ my $self = shift; my $style = shift; $self->{Style} = $style } sub setPriority{ my $self = shift; my $priority = shift; $self->{Priority} = $priority; } sub setHtml{ my $self = shift; my $html = shift; $self->{Html} = $html; } sub setPlain{ my $self = shift; my $plain = shift; $self->{Plain} = $plain; } sub setAttach{ my $self = shift; my $attach = shift; $self->{Attach} = $attach; } sub setSubject{ my $self = shift; my $subject = shift; $self->{Subject} = $subject; } sub setTo{ my $self = shift; my $to = shift; $self->{To} = $to; } sub setFrom{ my $self = shift; my $from = shift; $self->{From} = $from; } sub setCc{ my $self = shift; my $cc = shift; $self->{Cc} = $cc; } sub setBcc{ my $self = shift; my $bcc = shift; $self->{Bcc} = $bcc; } sub setMailprog{ my $self = shift; my $mailprog = shift; $self->{Mailprog} = $mailprog; } sub setReplyto{ my $self = shift; my $replyto = shift; $self->{Replyto} = $replyto; } sub makehtml { my $body = shift; $body =~ s/ftp:\S+/$&<\/A>/gs; $body =~ s/http:\S+/$&<\/A>/gs; $body =~ s/https:\S+/$&<\/A>/gs; my $htmlbody = "
 
$body <\/font><\/PRE>";

     return $htmlbody
}

sub makeplain
{
     my ($line, $plaintext, @plain);

     my $html = shift;

     my @HTML = split(/(<[^>]*>)/, $html);

     foreach $line (@HTML)
     {
         $line =~ s/\n//g;
         $line =~ s/^\s+//g;
         $line =~ s/\s+$//g;
         $line =~ 
s/<\s*HR*>/-----------------------------------------------------------\n/i;
         ($line =~ m#<\s*/TD>#i) && push(@plain, "      ");
         ($line =~ m#<\s*/TR>#i) && push(@plain, "\n");
         ($line =~ m#<\s*TABLE>#i) && push(@plain, "\n");
         ($line =~ m#<\s*BR>#i) && push(@plain, "\n");
         ($line =~ m#<\s*/DIV>#i) && push(@plain, "\n\n");
         ($line =~ m#<\s*/P>#i) && push(@plain, "\n\n");
         ($line =~ m#<*>#) && (next);
         push(@plain, "$line");
     }

     $plaintext = join(' ', @plain);
     return $plaintext;

}

sub old_encode_base64 ($;$)
{
     my $res = "";
     my $eol = $_[1];
     $eol = "\n" unless defined $eol;
     pos($_[0]) = 0;                          # ensure start at the beginning

     $res = join '', map( pack('u',$_)=~ /^.(\S*)/, ($_[0]=~/(.{1,45})/gs));

     $res =~ tr|` -_|AA-Za-z0-9+/|;               # `# help emacs
     # fix padding at the end
     my $padding = (3 - length($_[0]) % 3) % 3;
     $res =~ s/.{$padding}$/'=' x $padding/e if $padding;
     # break encoded string into lines of no more than 76 characters each
     if (length $eol) {
         $res =~ s/(.{1,76})/$1$eol/g;
     }
     return $res;
}


1;

__END__

=head1 NAME

Mailsend.pm

=head1 SYNOPSIS


  $msg1 = Mailsend->new();


  $msg1->setTo('spike@mweb.com, recipient2@foo.com, ...');


  $msg1->setSubject("$subject");


  $msg1->setFrom('spike@mweb.co.za');


  $msg1->setStyle('plain'); or 'html' or 'both'


  $msg1->setPlain("$plain_message_text")


  #msg1->sethtml("$html_message_code")


  $msg1->setMailprog('/path/to/sendmail');


  $msg1->setReplyto('sender@mweb.com');


  $msg1->setCc('cc_recipient1@inode.co.za,
                cc_recipient2@inode.co.za,
                ...');


  $msg1->setBcc('bcc_recipient1@inode.co.za,
                 bcc_recipient2@inode.co.za,
                 ...');


  $msg1->setAttach('/root/file1, /var/log/file2.txt,
                    /home/me/file3, ...');


  $msg1->setPriority('1') # 1 high to 5 low. 3 normal.


  $msg1->send();

=head1 DESCRIPTION


This perl Module will provide a simple interface to Sendmail.
It must be copied to your library path.
To see a path list type:  "perl -e 'print join("\n", @INC)'"

Various methods allow a mail to be sent to multiple recipients
in plain text, html or both, with or without multiple attachments.
The only obligatory methods Mailsend->new() and  setTo("address")
and send().

If the style is set to html and only a setPlain message body is
specified the plain text message will be set to html with a non-serif
font (more readable on screen) and any URLs will be expanded with
html tags to make them 'clickable'.

If the style is set to plain and only an html message body is set
an attempt to convert the html to plain text will be made. Note
that the results will probably be ugly.

If no style is set the setStyle will be defaulted to 'both' and
any necessary conversions made in accordance with the rules above.

A message with an attachment set with setAttach will have it's style
set to 'both'. Attachments are base64 encoded.

A message "priority can be set with setPriority. It can be set to any
value but values fro 1-5 are supported by mosr clients. "1" is highest,
"5" Lowest and "3" is Normal priority.

Code for subroutine 'old_encode_base64' taken from MIME::Base64
by Gisle Aas .


=cut











Spike Hodge

UNIX Programmer
M-Web Technology
021 596 8496
082 901 5265

Click here and make M-Web your homepage
http://homepage.mweb.co.za 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030606/1560f8c3/attachment.htm
From scarte at pan.uzulu.ac.za  Fri Jun  6 04:43:21 2003
From: scarte at pan.uzulu.ac.za (Sean Carte)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Re: perldoc
In-Reply-To: <20030606094145.GC275@lt1.cleaton.net>
References: <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za>
	<20030604132145.GG269@lt1.cleaton.net>
	<5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za>
	<1054816852.16129.75.camel@seanc.uznet.uz>
	<20030605132507.GK262@lt1.cleaton.net>
	<1054819814.16519.130.camel@seanc.uznet.uz>
	<20030605140858.GL262@lt1.cleaton.net>
	<1054877938.16519.1106.camel@seanc.uznet.uz>
	<20030606081556.GB275@lt1.cleaton.net>
	<1054889721.16362.1391.camel@seanc.uznet.uz> 
	<20030606094145.GC275@lt1.cleaton.net>
Message-ID: <1054892601.16129.1428.camel@seanc.uznet.uz>

On Fri, 2003-06-06 at 11:41, Nick Cleaton wrote:
> It's not @ARGV in a scalar context, it's @ARGV interpolated into a
> doublequoted string.  When you interpolate an array into a string,
> you get all the elements of the array joined with $", which is a
> space by default.

Very clever! I had no idea you could do that; I've always used join '
',LIST to accomplish that in the past.
-- 
Regards
Sean Carte

University of Zululand
Network Services Unit
Phone: 035 902 6081
Fax: 035 902 6028

"From now on, I want you all to call me "Loretta""


From nick at cleaton.net  Fri Jun  6 05:41:20 2003
From: nick at cleaton.net (Nick Cleaton)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] oop
In-Reply-To: <5.2.1.1.0.20030606111644.0236d170@pop3.mweb.co.za>
References: <5.2.1.1.0.20030604140957.01edbe80@pop3.mweb.co.za> <20030604132145.GG269@lt1.cleaton.net> <5.2.1.1.0.20030605141503.023a39e8@pop3.mweb.co.za> <1054816852.16129.75.camel@seanc.uznet.uz> <20030605132507.GK262@lt1.cleaton.net> <1054819814.16519.130.camel@seanc.uznet.uz> <20030605140858.GL262@lt1.cleaton.net> <1054877938.16519.1106.camel@seanc.uznet.uz> <20030606081556.GB275@lt1.cleaton.net> <5.2.1.1.0.20030606111644.0236d170@pop3.mweb.co.za>
Message-ID: <20030606104120.GD275@lt1.cleaton.net>

On Fri, Jun 06, 2003 at 11:49:33AM +0200, Spike wrote:
> 
> I have written a object orientated perl module called Mailsend.pl.
> It give a very simple interface to sendmail and allows you to send HTML 
> formatted mail or plain or HTML and plain (multipart) and most importantly 
> attachments.

Have you looked at the MIME::Lite CPAN module ?  If I recall correctly
it does everything that Mailsend.pm does, and can also send via SMTP.

--
Nick

From nico at itfirms.co.za  Sat Jun  7 15:44:42 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] UPDATE
Message-ID: <200306072244.42645.nico@itfirms.co.za>

OK, I have added the first revision of the article on Perl Variables. You can 
find it here: http://za.pm.org/articles/001/index.html

This should give you an idea of what I plan. If you want to discuss the 
article itself, PLEASE start the subject line with [art001] so that I can 
archive the discussions on this article easier.

Thanks

PS: Input/Comments are most welcome :)

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.


From steve at dig.co.za  Sun Jun  8 11:48:20 2003
From: steve at dig.co.za (Steve Cox - dig)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] apache, cgi-bin, mdk9.1
In-Reply-To: <20030604143527.GI269@lt1.cleaton.net>
References: <3EDD92BC.7070706@cae.co.za> <20030604133235.GE21974@qualica.com> <20030604143527.GI269@lt1.cleaton.net>
Message-ID: <200306081848.20619.steve@dig.co.za>

Okay, I hope I can make this clear enough. If you might be able to help I can 
mail my .conf files off list.

I am running mdk9.1 with apache2, php, perl. Everything was working fine. I 
wanted to add other websites to dev on locally mainly, and went for the 
userdir option. I used that wiz in mandrake and things seemed to work okay. I 
have got my different websites, php works, and perl is running if I call the 
test.pl script from the cgi-bin. My problem. I have a perl script to search a 
csv file, and return the output to a html template and it worked b4 my 
change. It doesnt work now. My script keeps saying it cant open the csv file, 
which happens to be in the cgi-bin as well, at the same level at the script. 
I have been through the permissions over and over they seem fine. The csv 
file is fine. I have tried to call the csv file from the browser directly and 
I get an internal config error. I have tried with the csv file in the normal 
html page dir and I can call it fine. Put that in my .pl script, no go, still 
get that it cant open the .csv file. I have butchered my apache .conf files, 
and I just cant see what I need to change. If anyone has some advice or is 
will ing to look at my .conf files, please let me know.

Regards
Steve Cox.

From nick at cleaton.net  Mon Jun  9 02:51:28 2003
From: nick at cleaton.net (Nick Cleaton)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] apache, cgi-bin, mdk9.1
In-Reply-To: <200306081848.20619.steve@dig.co.za>
References: <3EDD92BC.7070706@cae.co.za> <20030604133235.GE21974@qualica.com> <20030604143527.GI269@lt1.cleaton.net> <200306081848.20619.steve@dig.co.za>
Message-ID: <20030609075128.GB275@lt1.cleaton.net>

On Sun, Jun 08, 2003 at 06:48:20PM +0200, Steve Cox - dig wrote:
> 
> I am running mdk9.1 with apache2, php, perl. Everything was working fine. I 
> wanted to add other websites to dev on locally mainly, and went for the 
> userdir option. I used that wiz in mandrake and things seemed to work okay. I 
> have got my different websites, php works, and perl is running if I call the 
> test.pl script from the cgi-bin. My problem. I have a perl script to search a 
> csv file, and return the output to a html template and it worked b4 my 
> change. It doesnt work now. My script keeps saying it cant open the csv file, 
> which happens to be in the cgi-bin as well, at the same level at the script. 
> I have been through the permissions over and over they seem fine. The csv 
> file is fine. I have tried to call the csv file from the browser directly and 
> I get an internal config error. I have tried with the csv file in the normal 
> html page dir and I can call it fine. Put that in my .pl script, no go, still 
> get that it cant open the .csv file. I have butchered my apache .conf files, 
> and I just cant see what I need to change. If anyone has some advice or is 
> will ing to look at my .conf files, please let me know.

Try putting the full path to the csv file into the script, so instead
of something like:

  open CSV, "
References: <200306072244.42645.nico@itfirms.co.za>
Message-ID: <20030609083608.GC275@lt1.cleaton.net>

> http://za.pm.org/articles/001/index.html

That's a nice introduction, just a couple of comments about some
of the code:


> print "\'$_\' " foreach @ARGV;

You don't need to escape the singlequotes there, and I think
the extra backslashes make it more confusing than it needs to
be.

  print "'$_' " foreach @ARGV;


> for ( $t = 1; $t < 5; $t++ ) {

That's the C way of doing for loops, it can be written in Perl
as:

  for $t ( 1..4 ) {

... which might be less confusing for those without a C
background.

A couple of typos:

> # A hash is similar to a hash, whith the distinct difference that the

  # A hash is similar to an array, with the distinct difference that the

--
Nick

From scarte at pan.uzulu.ac.za  Mon Jun  9 08:45:49 2003
From: scarte at pan.uzulu.ac.za (Sean Carte)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] [art001] comments
In-Reply-To: <20030609083608.GC275@lt1.cleaton.net>
References: <200306072244.42645.nico@itfirms.co.za> 
	<20030609083608.GC275@lt1.cleaton.net>
Message-ID: <1055166350.16129.1539.camel@seanc.uznet.uz>

I'll just make the odd (hopefully not too pedantic) note as I read
through it:

http://za.pm.org/articles/001/index.html
Various other Perl functions are also used, and I will try to explain as
good as I can as I go along.
-> ... used, which I will try to explain as well as ...
1
shabang
-> In the Camel it's 'shebang' (2nd Ed. p. 11).
43 to 49
... incrementing with 1 after each loop ( $t++ ), DO ( { )". 
? -> DO {}".
71 and 72
... straight forward
-> straightforward
75 to 81
... and place in in a scalar
-> them in a scalar

http://za.pm.org/articles/001/intro_pl.html
11 # Scalars are variables that stores a single data entity, which can
be
-> store
30 # Areays are variables that stores various bit's of information in
-> Arrays
-> bits
31 # seperate containers, which has a numerical index. A good example,
is
-> separate

I agree with Nick's comment about the use of superfluous escapes: I'd
rather they were gone.

I look forward to reading the rest.
-- 
Regards
Sean Carte

University of Zululand
Network Services Unit
Phone: 035 902 6081
Fax: 035 902 6028

"An empty desk is an efficient desk!" -- Warren


From scarte at pan.uzulu.ac.za  Mon Jun  9 09:01:52 2003
From: scarte at pan.uzulu.ac.za (Sean Carte)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] [art001] comments
In-Reply-To: <1055166350.16129.1539.camel@seanc.uznet.uz>
References: <200306072244.42645.nico@itfirms.co.za> 
	<20030609083608.GC275@lt1.cleaton.net> 
	<1055166350.16129.1539.camel@seanc.uznet.uz>
Message-ID: <1055167312.16362.1542.camel@seanc.uznet.uz>

Sorry, I just spotted another grammatical error:

On Mon, 2003-06-09 at 15:45, Sean Carte wrote:
> 31 # seperate containers, which has a numerical index. A good example,
> is
> -> separate
-> which have ...

I'll stop now. ;->
-- 
Regards
Sean Carte

University of Zululand
Network Services Unit
Phone: 035 902 6081
Fax: 035 902 6028

"An empty desk is an efficient desk!" -- Warren


From steve at dig.co.za  Mon Jun  9 12:48:05 2003
From: steve at dig.co.za (Steve Cox - dig)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Re: apache, cgi-bin, mdk9.1
In-Reply-To: <200306081848.20619.steve@dig.co.za>
References: <3EDD92BC.7070706@cae.co.za> <20030604143527.GI269@lt1.cleaton.net> <200306081848.20619.steve@dig.co.za>
Message-ID: <200306091948.06046.steve@dig.co.za>

On Sunday, 8 June 2003 18:48, you wrote:
> Okay, I hope I can make this clear enough. If you might be able to help I
> can mail my .conf files off list.
>
> I am running mdk9.1 with apache2, php, perl. Everything was working fine. I
> wanted to add other websites to dev on locally mainly, and went for the
> userdir option. I used that wiz in mandrake and things seemed to work okay.
> I have got my different websites, php works, and perl is running if I call
> the test.pl script from the cgi-bin. My problem. I have a perl script to
> search a csv file, and return the output to a html template and it worked
> b4 my change. It doesnt work now. My script keeps saying it cant open the
> csv file, which happens to be in the cgi-bin as well, at the same level at
> the script. I have been through the permissions over and over they seem
> fine. The csv file is fine. I have tried to call the csv file from the
> browser directly and I get an internal config error. I have tried with the
> csv file in the normal html page dir and I can call it fine. Put that in my
> .pl script, no go, still get that it cant open the .csv file. I have
> butchered my apache .conf files, and I just cant see what I need to change.
> If anyone has some advice or is will ing to look at my .conf files, please
> let me know.
>
> Regards
> Steve Cox.

Okay I got it to work. I have had to specify the .csv file and also the 
template the script writes to with the full path from root, which is like:
/home/aptsa/htmldocs/cgi-bin/stkdata/search.pl
/home/aptsa/htmldocs/template.html

This is not too bad, but I would prefer referring to the files with just:
/cgi-bin/stkdata/search.pl
template.html

This might be going extending the perl part a bit far, but if anyone spots 
anything obvious I would appreciate it.

Is this set in apache or where should I be looking. It is difficult with 
docroot setting which is set as /home reason being the way the different 
sites are set by users, take a look at the following snippets from the 
commonhttpd.conf file I have:


    UserDir htmldocs

# Start aliases

        Alias /icons/ /var/www/icons/
        Alias /doc /usr/share/doc
        Alias /cgi-bin/ /home/*/htmldocs/cgi-bin/
    
        #Provide two aliases to the same cgi-bin directory,
        #to see the effects of the 2 different mod_perl modes
        #for Apache::Registry Mode
        Alias /perl/ /home/*/htmldocs/cgi-bin/
        #for Apache::Perlrun Mode
        Alias /cgi-perl/ /home/*/htmldocs/cgi-bin/
    

# End of aliases.
# This should be changed to whatever you set DocumentRoot to.

        Options -Indexes FollowSymLinks MultiViews  ExecCGI
        AllowOverride All
        
        Order allow,deny
        Allow from all
        


        AllowOverride All
        Options -Indexes FollowSymLinks MultiViews ExecCGI
        
        Order allow,deny
        Allow from all
        


        AllowOverride All
        Options -Indexes FollowSymLinks MultiViews ExecCGI
        
        Order allow,deny
        Allow from all
        


Regards
Steve Cox.

From nico at itfirms.co.za  Tue Jun 10 13:42:38 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] [art001] comments
In-Reply-To: <20030609083608.GC275@lt1.cleaton.net>
References: <200306072244.42645.nico@itfirms.co.za> <20030609083608.GC275@lt1.cleaton.net>
Message-ID: <200306102042.38262.nico@itfirms.co.za>

On Monday 09 June 2003 10:36, Nick Cleaton wrote:
> > http://za.pm.org/articles/001/index.html
>
> That's a nice introduction, just a couple of comments about some
>
> of the code:
> > print "\'$_\' " foreach @ARGV;
>
> You don't need to escape the singlequotes there, and I think
> the extra backslashes make it more confusing than it needs to
> be.
>
>   print "'$_' " foreach @ARGV;
>

Of course you are right :) My excuse (this time) - it was late... hehe

> > for ( $t = 1; $t < 5; $t++ ) {
>
> That's the C way of doing for loops, it can be written in Perl
> as:
>
>   for $t ( 1..4 ) {
>

I will add the alternative. Believe it or not, I find it easier to keep to the 
C style for some reason.

> ... which might be less confusing for those without a C
> background.
>
> A couple of typos:
> > # A hash is similar to a hash, whith the distinct difference that the
>
>   # A hash is similar to an array, with the distinct difference that the
>

I confess - I'm not at all the worlds greates speller, and it seems the Quanta 
Spell Check isn't perfect either :) I will correct these with the next run.

> --
> Nick
> _______________________________________________
> Za-pm mailing list
> Za-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/za-pm

Cheers

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.


From nico at itfirms.co.za  Tue Jun 10 13:43:18 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] [art001] comments
In-Reply-To: <1055166350.16129.1539.camel@seanc.uznet.uz>
References: <200306072244.42645.nico@itfirms.co.za> <20030609083608.GC275@lt1.cleaton.net> <1055166350.16129.1539.camel@seanc.uznet.uz>
Message-ID: <200306102043.18619.nico@itfirms.co.za>

Thanks - I will do the changes on the next release.

Cheers

On Monday 09 June 2003 15:45, Sean Carte wrote:
> I'll just make the odd (hopefully not too pedantic) note as I read
> through it:
>
> http://za.pm.org/articles/001/index.html
> Various other Perl functions are also used, and I will try to explain as
> good as I can as I go along.
> -> ... used, which I will try to explain as well as ...
> 1
> shabang
> -> In the Camel it's 'shebang' (2nd Ed. p. 11).
> 43 to 49
> ... incrementing with 1 after each loop ( $t++ ), DO ( { )".
> ? -> DO {}".
> 71 and 72
> ... straight forward
> -> straightforward
> 75 to 81
> ... and place in in a scalar
> -> them in a scalar
>
> http://za.pm.org/articles/001/intro_pl.html
> 11 # Scalars are variables that stores a single data entity, which can
> be
> -> store
> 30 # Areays are variables that stores various bit's of information in
> -> Arrays
> -> bits
> 31 # seperate containers, which has a numerical index. A good example,
> is
> -> separate
>
> I agree with Nick's comment about the use of superfluous escapes: I'd
> rather they were gone.
>
> I look forward to reading the rest.

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.


From nico at itfirms.co.za  Tue Jun 17 12:23:01 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Fwd: FOR PERLMONGERS "Practical mod_perl" Released by O'Reilly (fwd)
Message-ID: <200306171923.01967.nico@itfirms.co.za>

FYI:

----------  Forwarded Message  ----------

Subject: FOR PERLMONGERS "Practical mod_perl" Released by O'Reilly (fwd)
Date: Saturday 14 June 2003 12:29
From: "Frederick Noronha (FN)" 
To: nico@itfirms.co.za

---------- Forwarded message ----------

For Immediate Release
For more information, a review copy, cover art, or an interview with
the authors, contact:
Kathryn Barrett (707) 827-7094 or kathrynb@oreilly.com


New Book Offers a Wealth of Knowledge from the mod_perl Community
O'Reilly Releases "Practical mod_perl"

Sebastopol, CA--Web developers and administrators know that the speed
of a web server often has very little to do with the server itself. If
a site is slow, it's invariably caused by back-end applications like
CGI scripts that take longer than they should to run. mod_perl is an
Apache server module that provides huge performance benefits for
Perl-based CGI scripts. By switching to mod_perl, web programmers and
administrators see immediate improvements in efficiency.  But
optimizing its performance can be tricky. While mod_perl is fairly easy
to install and run, tweaking mod_perl and Apache for the best
performance and reliability is more difficult. "Practical mod_perl" by
Stas Bekman and Eric Cholet (O'Reilly, US $49.95) is the definitive
book about building mod_perl, using it, programming with it, and
optimizing it.

In "Practical mod_perl" new users will learn how to quickly and easily
get mod_perl compiled and installed. But the primary purpose of the
book is to show Perl web developers and administrators how to take full
advantage of mod_perl: how to make a mod_perl-enabled web site as fast,
flexible, and easily-maintainable as possible. The authors draw from
their own personal experience in the field, as well as the combined
experience of the mod_perl community, to present a rich and complete
picture of how to set up and maintain a successful mod_perl site.

Coauthor Bekman explains that many books are based on the knowledge and
expertise of a single person, but "Practical mod_perl" is based on the
expertise of the huge community, which encompasses much more than a
single person could gain from experience and observation. "This book
comprises the knowledge base of the mod_perl community collected over
the last five years, combined with the authors' personal experience in
the field," Bekman says. "Therefore, it answers almost any questions
that mod_perl users have asked over these years."

Coauthor Cholet adds, "Most technical books are focused on a
technology: many books about web application development will teach the
reader how to program using a particular set of tools. We feel that
writing and maintaining a web site is much more than that.  Our book
aims to include all aspects of development and maintenance."

Readers will find thorough discussions about the Perl programming
language, Apache's Perl API, and scripts that run under
Apache::Registry.  The book covers the following topics, and more:

-Configuring mod_perl optimally for your web site
-Porting and optimizing programs for a mod_perl environment
-Performance tuning: getting the very fastest performance from your site
-Controlling and monitoring the server to circumvent crashes and clogs
-Integrating with databases efficiently and painlessly
-Debugging tips and tricks
-Maximizing security

Written for Perl web developers and web administrators, "Practical
mod_perl" is an extensive guide to the nuts and bolts of this popular
module. From writing and debugging scripts to keeping a server running
without failures, the techniques in this book will help readers squeeze
every ounce of power out of their servers.


Additional Resources
"Practical mod_perl" is also available on the O'Reilly Network Safari
Bookshelf, see:
http://safari.oreilly.com/

Don't miss Stas Bekman's tutorial (July 7) or session (July 9) at the
2003 O'Reilly Open Source Convention in Portland, OR:
http://conferences.oreilly.com/oscon/

Chapter 6, "Coding with mod_perl in Mind," is available free online at:
http://www.oreilly.com/catalog/pmodperl/chapter/index.html

For more information about the book, including Table of Contents,
index, author bios, and samples, see:
http://www.oreilly.com/catalog/pmodperl/

For a cover graphic in JPEG format, go to:
ftp://ftp.ora.com/pub/graphics/book_covers/hi-res/0596002270.jpg

Practical mod_perl
Stas Bekman and Eric Cholet
ISBN 0-596-00227-0, 893 pages, $49.95 (US), $77.95 (CAN)
order@oreilly.com
1-800-998-9938
1-707-827-7000
http://www.oreilly.com

About O'Reilly
O'Reilly & Associates is the premier information source for
leading-edge computer technologies. The company's books, conferences,
and web sites bring to light the knowledge of technology innovators.
O'Reilly books, known for the animals on their covers, occupy a
treasured place on the shelves of the developers building the next
generation of software. O'Reilly conferences and summits bring alpha
geeks and forward-thinking business leaders together to shape the
revolutionary ideas that spark new industries. From the Internet to
XML, open source, .NET, Java, and web services, O'Reilly puts
technologies on the map. For more information: http://www.oreilly.com

# # #

O'Reilly is a registered trademark of O'Reilly & Associates, Inc. All
other trademarks are property of their respective owners.

-------------------------------------------------------

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.


From kmf at pop.co.za  Mon Jun 23 03:49:19 2003
From: kmf at pop.co.za (kmf@pop.co.za)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Problem with array.
Message-ID: 

Hi 
I'm a uber noob to perl. 
I trying a basic perl app. With the following 
objectives. Placing the different users in 
different categories. 
 
Sorry 
forgive me for pasting the code I don't know the rules. 
 
Thanks  
  Karl 

____________________________________________________________ 
#!/usr/bin/perl 
-w 
$a="Are they good or evil?"; 
@good=qw(Neo Trinity Morpheus); 

@builder=qw(Oracle Architect); 
@bad=qw(Smith Agents Agent Twins); 
print 
("Enter the name to see if you can trust them \n"); 
print ("$a \n"); 
print 
("What is Your Name? \n"); 
$name=; 
chomp $name; 
if ($name=@good){print 
"Your are here to change everyone. \n" 
} #else { print"I don't know you!" }; 
 
elsif ($name=@builder){print "Your are a builder of the Matrix \n" 
  } elsif 
($name=@bad){print "Uber Eek! I won't mess with you \n" 
}; 


From spikeh at mweb.co.za  Mon Jun 23 04:49:54 2003
From: spikeh at mweb.co.za (Spike)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Problem with array.
In-Reply-To: 
Message-ID: <5.2.1.1.0.20030623105119.01d77b50@pop3.mweb.co.za>


#!/usr/bin/perl -w
# put -w on same line as #!perl

$a="Are they good or evil?";

@good=qw(Neo Trinity Morpheus);

@builder=qw(Oracle Architect);

@bad=qw(Smith Agents Agent Twins);

print ("Enter the name to see if you can trust them \n");
# brackets are not needed here - but it will still work.

print "Enter the name to see if you can trust them \n";

print ("$a \n");
print ("What is Your Name? \n");
$name=;
chomp $name;

#if ($name=@good){ # This won't work as you are assigning
                    # the array @good to the var $name,
                    # not what you want, you want to test
                    # if the $name is in @good so use grep

print "Your are here to change everyone. \n"

if ( grep("$name", @good) ) {

print "Your are here to change everyone. \n" ;   # you missed the semi-colon
}
else {
print "I might kb=know you but you ar not good\n";
# }; don't need semi-colon after a block
}

... etc.


PS don't forget that '=' assigns a value and (for numbers) '==' tests for 
equality (for strings it's 'eq')



Spike Hodge

UNIX Programmer
M-Web Technology
021 596 8496
082 901 5265

Click here and make M-Web your homepage
http://homepage.mweb.co.za 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030623/6f86e4c7/attachment.htm
From kmf at pop.co.za  Mon Jun 23 05:21:41 2003
From: kmf at pop.co.za (kmf@pop.co.za)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Problem with array.
Message-ID: 

Thanks I'll try 
btw my I pasted the code direct from xterm to the webclient ... 

The formatting looked fine when I mailed it guess not :) 
 
Karl 
 
--- Spike 
 wrote: 
 
> #!/usr/bin/perl -w   
> # put -w on same line as 
#!perl 
>  
> $a="Are they good or evil?";  
>  
> @good=qw(Neo Trinity 
Morpheus);  
>  
> @builder=qw(Oracle Architect); 
>   
> @bad=qw(Smith Agents 
Agent Twins);  
>  
> print ("Enter the name to see if you can trust them \n");  

 
> # brackets are not needed here - but it will still work. 
>  
> print 
"Enter the name to see if you can trust them 
\n"; 
>  
> print ("$a \n");  
> 
print ("What is Your Name? \n");  
> $name=;  
> chomp $name;  
>  
> #if 
($name=@good){ # This won't work as you are assigning 
>                    
# 
the array @good to the var $name,  
>                    
# not what you want, 
you want to test  
>                    
# if the $name is in @good so use grep 

>  
> print "Your are here to change everyone. \n"  
>  
> if ( grep("$name", 
@good) ) { 
>  
> print "Your are here to change everyone. \n" ;   
# you missed 
the semi-colon 
> }  
> else {  
> print "I might kb=know you but you ar not 
good\n"; 
> # }; don't need semi-colon after a block 
> } 
>   
> .... etc. 
>  

>  
> PS don't forget that '=' assigns a value and (for numbers) '==' tests for 

equality (for strings it's 'eq') 
>  
>  
>  
> Spike Hodge 
>  
> UNIX 
Programmer 
> M-Web 
Technology 
> 021 596 8496 
> 082 901 5265 
>  
> Click 
here and make M-Web your homepage 
> http://homepage.mweb.co.za 


From Pritesh at aptronics.co.za  Mon Jun 23 07:26:12 2003
From: Pritesh at aptronics.co.za (Pritesh Jewan)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Regular expression help needed
Message-ID: 

Hello people,
 
I have a few regular expressions from a script that I am trying to update
and needed some assistance with what the expression mean:
 
===============================
while(){
next if (/^#/);
next if (/^$/);
$match = 1;
 
I'm trying to understand the second and third line.
===============================
The script has this line in a few places. Can't seem to find any doco that
would explain what it means:
 
s(\n)();
===============================
 
s/\n$//;
 
===============================
(!/^$/)||next;
(!/^#/)||next;
 
Any assistance is greatly appreciated
 
Regards
Pritesh
 
 
Pritesh Jewan 
Aptronics (Pty) Ltd
Tel   : +27 11 791 0180
Fax  : +27 11 791 0183
Cell : 084-677-2486
  pritesh@aptronics.co.za
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030623/e5bd6cd4/attachment.htm
From oskar at qualica.com  Mon Jun 23 07:55:35 2003
From: oskar at qualica.com (Oskar Pearson)
Date: Mon Aug  2 21:39:59 2004
Subject: [Za-pm] Regular expression help needed
In-Reply-To: 
References: 
Message-ID: <20030623125535.GX4881@qualica.com>

Hi

> I have a few regular expressions from a script that I am trying to update
> and needed some assistance with what the expression mean:
>  
> ===============================
> while(){
> next if (/^#/);
> next if (/^$/);
> $match = 1;
>  
> I'm trying to understand the second and third line.


^ means "beginning of line", $ means "end of line", this these mean:
skip the line if it starts with a # (comment character, I guess
and skip the line if it's blank.

> ===============================
> The script has this line in a few places. Can't seem to find any doco that
> would explain what it means:
>  
> s(\n)();

you can use "(" or many other characters instead of "/" in regular
expressions. This that basically means the same as s/\n///;, which
means "remove blank lines". I think that the author may be misguided there,
though, as the earlier line should have meant the same thing.

> ===============================
>  
> s/\n$//;
>  


same as above.

> ===============================
> (!/^$/)||next;
> (!/^#/)||next;


if (! blank line or comment) { next; }
(which is wierd.... I think!)

--
Oskar Pearson 
Qualica Technologies (Pty) Ltd
web: http://www.qualica.com/

From nick at cleaton.net  Mon Jun 23 08:26:49 2003
From: nick at cleaton.net (Nick Cleaton)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] Regular expression help needed
In-Reply-To: 
References: 
Message-ID: <20030623132649.GC290@lt1.cleaton.net>

On Mon, Jun 23, 2003 at 02:26:12PM +0200, Pritesh Jewan wrote:
>  
> I have a few regular expressions from a script that I am trying to update
> and needed some assistance with what the expression mean:
>  
> ===============================
> while(){
> next if (/^#/);

'next' means jump to the next go around the loop.

'if (/^#/)' means 'if the current line starts with a #'.

So that line jumps to the next go around the while loop (i.e. goes
on to the next line from GWTABLE) if the current line starts with
a '#'.

> next if (/^$/);

Similar, but '$' means the end of the string, so this one does a
'next' if the line is empty.

You don't need the brackets on those, and I find them more readable
without brackets, so I would write those as:

  next if /^#/;
  next if /^$/;

> $match = 1;
>  
> I'm trying to understand the second and third line.
> ===============================
> The script has this line in a few places. Can't seem to find any doco that
> would explain what it means:
>  
> s(\n)();

That deletes the newline from the end of the line.  I prefer to write
that as:

  chomp;

since I find that more readable.

> s/\n$//;

Ditto.  I would also rewrite that as:

  chomp;

> ===============================
> (!/^$/)||next;
> (!/^#/)||next;

Those are confusing double negatives.  They jump to the next go
around the loop if the pattern matches.  I would rewrite those
as:

  next if /^$/;
  next if /^#/;

--
Nick

From spikeh at mweb.co.za  Mon Jun 23 08:40:50 2003
From: spikeh at mweb.co.za (Spike)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] Regular expression help needed
In-Reply-To: 
Message-ID: <5.2.1.1.0.20030623153916.01dfd618@pop3.mweb.co.za>

$match = 1 looks a bit dodgey - might mean $match = $1 to capture the 
comment line.



At 2003/06/23 02:26 PM, Pritesh Jewan wrote:

>Hello people,
>
>
>
>I have a few regular expressions from a script that I am trying to update 
>and needed some assistance with what the expression mean:
>
>
>
>===============================
>
>while(){
>
>next if (/^#/);
>
>next if (/^$/);
>
>$match = 1;
>
>
>
>I'm trying to understand the second and third line.
>
>===============================
>
>The script has this line in a few places. Can't seem to find any doco that 
>would explain what it means:
>
>
>
>s(\n)();
>
>===============================
>
>
>
>s/\n$//;
>
>
>
>===============================
>
>(!/^$/)||next;
>
>(!/^#/)||next;
>
>
>
>Any assistance is greatly appreciated
>
>
>
>Regards
>
>Pritesh
>
>
>
>
>
>Pritesh Jewan
>Aptronics (Pty) Ltd
>Tel   : +27 11 791 0180
>Fax  : +27 11 791 0183
>Cell : 084-677-2486
>pritesh@aptronics.co.za
>
>
>
>


Spike Hodge

UNIX Programmer
M-Web Technology
021 596 8496
082 901 5265

Click here and make M-Web your homepage
http://homepage.mweb.co.za 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030623/9cb6108a/attachment.htm
From nico at itfirms.co.za  Mon Jun 23 12:59:55 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] General Notice
Message-ID: <200306231959.55143.nico@itfirms.co.za>

Hi

Some of you might have noticed that I am a bit quite in here. My wife has 
accepted a post in the UAE, which means she will be making about three times 
more money then me - tax free :-D

Anyway, this is the last week for the next six months we are together, so I 
guess it's like a 'honeymoon' :)

I will read the rest of the mails and do some updates from Sunday onward.

Cheers

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.


From spikeh at mweb.co.za  Thu Jun 26 04:18:37 2003
From: spikeh at mweb.co.za (Spike)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] perl -> MS SQLserver
In-Reply-To: <200306231959.55143.nico@itfirms.co.za>
Message-ID: <5.2.1.1.0.20030626111642.038c4148@pop3.mweb.co.za>

Have any of you successfully connected to a MS SQL Server database with 
PERL from a UNIX machine?
... or even met anyone who has!


Spike Hodge

UNIX Programmer
M-Web Technology
021 596 8496
082 901 5265

Click here and make M-Web your homepage
http://homepage.mweb.co.za 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030626/2106ff5c/attachment.htm
From oskar at qualica.com  Thu Jun 26 05:38:24 2003
From: oskar at qualica.com (Oskar Pearson)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] perl -> MS SQLserver
In-Reply-To: <5.2.1.1.0.20030626111642.038c4148@pop3.mweb.co.za>
References: <200306231959.55143.nico@itfirms.co.za> <5.2.1.1.0.20030626111642.038c4148@pop3.mweb.co.za>
Message-ID: <20030626103824.GL21021@qualica.com>

Hi

> Have any of you successfully connected to a MS SQL Server database with 
> PERL from a UNIX machine?
> ... or even met anyone who has!

Yes.

You can use "freetds" with specific versions of SQL server at
least. You'll need to set up freetds first, and then compile
the perl DBD type libraries to link against it.

It's not the best software on earth, by the way - do some
extensive testing to ensure it's not giving you bogus results;
I've had problems with, for example, very very large numbers
being fed back wrong.

Oskar
--
Oskar Pearson 
Qualica Technologies (Pty) Ltd
web: http://www.qualica.com/

From oskar at qualica.com  Thu Jun 26 05:44:35 2003
From: oskar at qualica.com (Oskar Pearson)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] perl -> MS SQLserver
In-Reply-To: <20030626103824.GL21021@qualica.com>
References: <200306231959.55143.nico@itfirms.co.za> <5.2.1.1.0.20030626111642.038c4148@pop3.mweb.co.za> <20030626103824.GL21021@qualica.com>
Message-ID: <20030626104435.GM21021@qualica.com>

Hi


> It's not the best software on earth, by the way - do some
> extensive testing to ensure it's not giving you bogus results;
> I've had problems with, for example, very very large numbers
> being fed back wrong.

Sorry to reply to my own reply. Just a note that the above was
with freetds 0.53-7 - I don't know if later versions are
better.

http://www.freetds.org/

Latest version is 0.61.

The numbers were numeric(18,0)s, if I remember correctly.

Oskar
--
Oskar Pearson 
Qualica Technologies (Pty) Ltd
web: http://www.qualica.com/

From spikeh at mweb.co.za  Fri Jun 27 05:30:41 2003
From: spikeh at mweb.co.za (Spike)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] perl -> MS SQLserver
In-Reply-To: <20030626104435.GM21021@qualica.com>
References: <20030626103824.GL21021@qualica.com>
 <200306231959.55143.nico@itfirms.co.za>
 <5.2.1.1.0.20030626111642.038c4148@pop3.mweb.co.za>
 <20030626103824.GL21021@qualica.com>
Message-ID: <5.2.1.1.0.20030627122411.01e4d680@pop3.mweb.co.za>

All working fine!

M$ SQL is a pain but I now have a perl script on my LINUX box that queries 
a MS SQLservr 2000 database onon an NT box.

I am useing the Sybase::DBD module which happily talks to MS via the TDS 
protocol with no ODBC cluients in the way to complicate and slow things down.

Hell - I think I shall have the rest of the day off

Thanks Oscar for the pointer to freetds.org


At 2003/06/26 12:44 PM, Oskar Pearson wrote:
>Hi
>
>
> > It's not the best software on earth, by the way - do some
> > extensive testing to ensure it's not giving you bogus results;
> > I've had problems with, for example, very very large numbers
> > being fed back wrong.
>
>Sorry to reply to my own reply. Just a note that the above was
>with freetds 0.53-7 - I don't know if later versions are
>better.
>
>http://www.freetds.org/
>
>Latest version is 0.61.
>
>The numbers were numeric(18,0)s, if I remember correctly.
>
>Oskar
>--
>Oskar Pearson 
>Qualica Technologies (Pty) Ltd
>web: http://www.qualica.com/


Spike Hodge

UNIX Programmer
M-Web Technology
021 596 8496
082 901 5265

Click here and make M-Web your homepage
http://homepage.mweb.co.za 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030627/9c44f0cb/attachment.htm
From nico at itfirms.co.za  Sun Jun 29 06:44:37 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] perl -> MS SQLserver
In-Reply-To: <20030626104435.GM21021@qualica.com>
References: <200306231959.55143.nico@itfirms.co.za> <20030626103824.GL21021@qualica.com> <20030626104435.GM21021@qualica.com>
Message-ID: <200306291344.37467.nico@itfirms.co.za>

On Thursday 26 June 2003 12:44, Oskar Pearson wrote:
> Hi
>
> > It's not the best software on earth, by the way - do some
> > extensive testing to ensure it's not giving you bogus results;
> > I've had problems with, for example, very very large numbers
> > being fed back wrong.
>
> Sorry to reply to my own reply. Just a note that the above was
> with freetds 0.53-7 - I don't know if later versions are
> better.
>
> http://www.freetds.org/
>
> Latest version is 0.61.

I am using this now, and it's stable and as fast as can be - except for MS SQL 
Server of course :(

I use the DBD::Sybase module, and currently I am duplicating certain info from 
the MS SQL Server to a MySQL server, because the MySQL server is much faster 
for generating reports.

I haven't seen any weird results returned yet, so I belief it's safe.

Cheers

PS: Application Developpers of the world - DON'T use MS SQL Server - *please*

hehehe

>
> The numbers were numeric(18,0)s, if I remember correctly.
>
> Oskar
> --
> Oskar Pearson 
> Qualica Technologies (Pty) Ltd
> web: http://www.qualica.com/
> _______________________________________________
> Za-pm mailing list
> Za-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/za-pm

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.


From nico at itfirms.co.za  Mon Jun 30 12:32:56 2003
From: nico at itfirms.co.za (Nico Coetzee)
Date: Mon Aug  2 21:40:00 2004
Subject: [Za-pm] FYI: IP to Integer and back
Message-ID: <200306301932.56021.nico@itfirms.co.za>

I don't know if some of you work a lot with IP addresses, but it's easier to 
manipulate large amounts of addresses if you work with the Integer value of 
an IP. Here is a short script to illustrate the use:


#!/usr/bin/perl

$ipnumber = ip2ipn( "192.168.0.1" );
if ( $ipnumber ) {
	print "IPN : $ipnumber\n";
	$ip = ipn2ip( $ipnumber );
	if ( $ip ) {
		print "IP  : $ip\n";
	}
}

sub ip2ipn {
	# this sub will change an IP to the Integer value
	if ( $_[0] =~ /^\d+\.\d+\.\d+\.\d+/ ) {
		$_[0] =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
		my $num = (16777216*$1)+(65536*$2)+(256*$3)+$4;
		return $num;
	} else {
		return 0;
	}
}

sub ipn2ip {
	# this sub returns the IP address from an Integer
	# logical range is from 0.0.0.1 to 255.255.255.255
	if ( ( $_[0] > 0 ) && ( $_[0] < 4294967295 ) ) {
		my $ipn = $_[0];
		my $w=($ipn/16777216)%256;
		my $x=($ipn/65536)%256;
		my $y=($ipn/256)%256;
		my $z=$ipn%256;
		my $ipn = $w . "." . $x . "." . $y . "." . $z;
		return $ipn;
	} else {
		return 0;
	}
}


I assume there are other modules to handle this - but then, this is a learning 
experience :) BTW - let's see how we can improve this - making the subs less 
lines etc.

Let me know what you people think...

Cheers

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.