From rbowen at rcbowen.com Tue Nov 2 12:12:18 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: November meeting Message-ID: <381F2982.C5B2C998@rcbowen.com> OK, guys, the meeting is a week away, and we don't have speakers yet. Any volunteers? Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rbowen at rcbowen.com Tue Nov 2 12:13:30 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: Makemaker Message-ID: <381F29CA.C3CABEB9@rcbowen.com> I keep hearing this rumor that Microsoft uses Makemaker to automate their build process. Or at least that they use Perl do do this. Does anyone have any more specific details on this. More specifically, do any of you guys use Perl to autoate your build process, and, if so, can you send me some sample code, or suggestions? Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From jgibson at lexmark.com Wed Nov 3 11:17:16 1999 From: jgibson at lexmark.com (John Gibson) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: Makemaker In-Reply-To: Your message of "Tue, 02 Nov 1999 13:13:30 EST." <381F29CA.C3CABEB9@rcbowen.com> Message-ID: <199911031717.MAA27533@interlock2.lexmark.com> We are looking at doing this also well as far as automating the pbuild process but there are some other reasons we want to do this. Anyhow This would definatly be a subject of intrest to me unfortunatly I cannot give to much of an insight to it at this point. maybe later after I have some of thei work done. Thanks -John jgibson@lexmark.com From rbowen at rcbowen.com Thu Nov 4 21:40:19 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: Monday's meeting Message-ID: <382251A3.B2CFF537@rcbowen.com> OK, guys, we still don't have a speaker or a topic for Monday's meeting. Are we still going to do it? Will it just be "Many Monkeys" and geeks dining together? I'll plan to bring some stuff from the Cookbook to talk about, but we really don't have an Advanced level talk, unless someone wants to volunteer NOW. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From ken.rietz at asbury.edu Fri Nov 5 06:54:22 1999 From: ken.rietz at asbury.edu (Rietz, Ken) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: RE: Monday's meeting Message-ID: Last meeting I mentioned the topic: the differences between lists and arrays. I can still mess up when to use ( .. ) and [ .. ]. Could someone talk on that? -- Ken Rietz -----Original Message----- From: Rich Bowen [mailto:rbowen@rcbowen.com] Sent: Thursday, November 04, 1999 10:40 PM To: perl mongers Subject: LPM: Monday's meeting OK, guys, we still don't have a speaker or a topic for Monday's meeting. Are we still going to do it? Will it just be "Many Monkeys" and geeks dining together? I'll plan to bring some stuff from the Cookbook to talk about, but we really don't have an Advanced level talk, unless someone wants to volunteer NOW. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From mawall0 at pop.uky.edu Fri Nov 5 15:42:25 1999 From: mawall0 at pop.uky.edu (Michael Wallace) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: November meeting Message-ID: <3.0.6.16.19991105154225.1b47ae7c@pop.uky.edu> If there is no advanced topic for the next meeting, maybe Rich could speak a bit longer from the Cookbook. The Perl novices (including me) would probably benefit from a longer talk. And maybe follow that up with a short 'Many Monkeys' session. Just a thought. Mike From hempy at ket.org Wed Nov 10 18:53:15 1999 From: hempy at ket.org (David Hempy) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: Notes from the November meeting In-Reply-To: <3.0.6.16.19991105154225.1b47ae7c@pop.uky.edu> Message-ID: <4.1.19991110194521.0393cc20@mail.ket.org> Enjoyed the meeting, as always. Learned new things, as always. Thanks again to Rich for keeping the information flowing! For those who didn't make it, here are some notes from the meeting: Attendees: 10 Beards: 5 Mustaches: 5 Bald/balding domes: 2 Capable of childbirth: 1 >From academia: 6 >From industry: 5 T-shirts: 3 Glasses: 5 pair Computers, laptop: 3 Computers, palmtop: 1 Non-Caucasians: 0 Tans: 0 Meat pizzas: 3 Veggie pizzas: 1 Pepperoni pizzas: 1 On-time pizzas: 0 Future orders from Papa John's: 0 Perl books: 6 Non-perl books: 0 Presenters owed gratitude: 1 Hope this helps, -dave -- David Hempy Internet Database Administrator Kentucky Educational Television From fprice at mis.net Thu Nov 11 01:18:43 1999 From: fprice at mis.net (Frank Price) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: regex snippets Message-ID: Hi lexpm! I have been dealing with some thorny regex's (thorny for me, that is) and thought I'd share some. Sorry this is kindof long. Interested in all comments ... First some background: this script is a crontab filter; it takes a crontab entry (crontab is the *nix facility for automatic job scheduling) and presents it in a more human readable format. A typical entry looks like this: 1,11,21,31,41,51 1-5,17-23 * * 2 /usr/local/bin/blah Which means "run /usr/local/bin/blah every Tuesday at 1,11,21,31,41, and 51 minutes past between 1 and 5 am and also between 5 and 11pm". Task 1) Take a string, which may contain commas and also ranges, and return a list of all the numbers. Ex: for "1-5,9,12" it should yield (1,2,3,4,5,9,12). Code 1) @list=splitcommas($entry); sub splitcommas { my ($string) = @_; if ( $string =~ s/(\d+)(-)(\d+)/join(',', ($1 .. $3))/e ) { splitcommas($string); } elsif ( $string =~ /,/ ) { # if at least one comma, split on it split(',', $string); } else { ($string); } # handles no commas or dash case; i.e. single num } Comment 1) The main work is done with the substitute in the "if". This pattern says "if you find two sets of integers joined by a dash, replace it with the inclusive range of those numbers joined by commas". Then we recuse on this fcn to split the commas. The cool thing about using the /e modifier is that the right hand side can be a perl expression. This let me just replace the ranges by a comma separated string, and it kept the entries in order. Took a while to get this one :-) Task 2) Pad all single digits in comma separated string with leading zero. So "1,3,5,10,12" yields "01,03,05,10,12". Code 2) $string =~ s/(,|^)(\d)(?=(?:,|$))/${1}0$2/g; Comment 2) Still not sure /exactly/ what's going on here! The lhs says "match either a comma or start-of-line; then a single digit; then just look ahead to see if the next character is either a comma or end-of-line." Parens around the first two make it remember the match. Then the rhs says "replace that with (comma or start-line) followed by 0 followed by the digit." The key (I think) is that the look ahead is what they call zero-width, so it doesn't actually increment the pattern matcher's record of where it is in the string. That's why I don't have to put the trailing comma/end-string back in. Another easier way would be to split on commas, pad each number with s/^(\d)$/0$1/, and then join again with commas. TMTOWTDI... Task 3) Take a list of numbers and change each to the correct cardinal (?) representation. Ex. (1,11,21) yields (1st, 11th, 21st). Code 3) foreach $day (@days) { if ( $day =~ /^1$/ || $day =~ /[^1]1$/ ) { $day .= "st" } elsif ( $day =~ /^2$/ || $day =~ /[^1]2$/ ) { $day .= "nd" } elsif ( $day =~ /^3$/ || $day =~ /[^1]3$/ ) { $day .= "rd" } else { $day .= "th" } } Comment 3) This is the one I mentioned at the meeting. Someone suggested a hash and that's a good solution in this case; but maybe not if the range gets bigger than 30 numbers! I would have like to put the match into one regex but thought it might slow it down. Here the logic is "if the number is a 1, or ends in a non-1 and then a 1, add an "st" to it." So on for 2 and 3; everything else falls thru to the "th" case. It is important to have the two disjuncts in that order, I think. Thanks for listening, and please tell me if you see better ways to do any of this! -Frank. -- Frank Price fprice@mis.net sub splitcommas { # take string with possible commas and ranges (-) # rtns array consisting of elts # E.g., hours entry = "0-6,9,12,15,17,19-23" # gives @=(0,1,2,3,4,5,6,9,12,15,17,19,20,21,22,23); my ($string) = @_; # This pattern says "if you find two sets of integers joined by a # dash, replace it with the inclusive range of those numbers joined # by commas". Then we recuse on this fcn to split the commas if ( $string =~ s/(\d+)(-)(\d+)/join(',', ($1 .. $3))/e ) { splitcommas($string); } elsif ( $string =~ /,/ ) { # if at least one comma, split on it split(',', $string); } else { ($string); } # handles no commas or dash case; i.e. single num } From rbowen at rcbowen.com Sat Nov 13 10:30:24 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: File::Find Message-ID: <382D9220.56E689F6@rcbowen.com> By the way, I appear to have made an error in my discussion of File::Find. I'm pretty sure that I said what the Cookbook says, so I'm a little confused. But, this is from the File::Find documentation: $File::Find::dir contains the current directory name, and $_ the current filename within that directory. $File::Find::name contains "$File::Find::dir/$_". I said that dir contains the directory relative to where you started, which is, I think, what the Cookbook says. I'll check the errata page to see. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From sungo at earthling.net Sat Nov 13 10:58:52 1999 From: sungo at earthling.net (Matt Cashner) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: silliness In-Reply-To: <382D9220.56E689F6@rcbowen.com> Message-ID: ok. for gits and shiggles, i'm playing with IRC and a perl bot. i'm basically hacking Josh Harding's bot based on Chatbot::Eliza (i said it was silly). by default the bot prints its main log to stdout. so for the time being i'm dumping it to a file (./elizairc.pl > main_log). the wierd part is that the file only is getting written to after i close the script. am i missing something in bash that i should know by now? :) also, if i'm reading things right, filehandles are local, correct? if so, what's the proper syntax to pass a filehandle to subroutines? or i smoking the wacky weed again? :) thanks all. --------------------- Matt Cashner sungo@earthling.net --------------------- "If we dont take care of the customer, maybe they'll stop bugging us." From rbowen at rcbowen.com Sat Nov 13 13:37:45 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: silliness References: Message-ID: <382DBE09.C64E871E@rcbowen.com> Matt Cashner wrote: > > ok. for gits and shiggles, i'm playing with IRC and a perl bot. i'm > basically hacking Josh Harding's bot based on Chatbot::Eliza (i said it > was silly). by default the bot prints its main log to stdout. so for the > time being i'm dumping it to a file (./elizairc.pl > main_log). the wierd > part is that the file only is getting written to after i close the > script. am i missing something in bash that i should know by now? :) $|=1; # Turn off buffering. > > also, if i'm reading things right, filehandles are local, correct? if so, > what's the proper syntax to pass a filehandle to subroutines? or i > smoking the wacky weed again? :) Prolly what you want to do is pass a typeglob. Or, you can use the File::IO module, which does some weird stuff, and lets you usea scalar as a file handle, or something like that. I've never used it, just read about it, but I'm pretty sure that's what you want to use. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From fprice at mis.net Sun Nov 14 00:40:42 1999 From: fprice at mis.net (Frank Price) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: silliness In-Reply-To: Message-ID: On Sat, 13 Nov 1999, Matt Cashner wrote: # also, if i'm reading things right, filehandles are local, correct? if so, # what's the proper syntax to pass a filehandle to subroutines? or i # smoking the wacky weed again? :) Well, I don't think you can just pass them like other variables. You can assign to a typeglob though. Since F is aliased to the typeglob inside the subroutine block, the value of the A (and B) gets restored once the block ends. There's probably another way to do this; I don't use it very often. sub prt { local *F = shift; my ($line) = @_; print F "$line\n"; } open (A, ">foo") or die "Can't open foo: $!\n"; prt(*A, 'Printing to foo ...'); close A; open(B, ">bar") or die "Can't open bar: $!\n"; prt(*B, 'printing to bar ...'); close B; -Frank. ____ ____ Frank Price Unix systems, Perl fprice@mis.net & Web Programming From rich at mullikin.com Mon Nov 15 16:48:43 1999 From: rich at mullikin.com (R Mullikin) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test Message-ID: <99111517493200.02787@localhost.localdomain> is this the list address? -- ============================================================================= Richard Mullikin www.horsedata.com Handicapper's Data Warehouse hdwinfo@horsedata.com ============================================================================= From grdodson at lexmark.com Mon Nov 15 18:51:12 1999 From: grdodson at lexmark.com (Graydon Dodson) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: silliness Message-ID: <199911160051.TAA06427@interlock2.lexmark.com> There is some black magic that you can do in perl to obtain a reference to a typeglob. This reference can now be treated as a filehandle stored in a variable including passing to subroutines etc. The really cool thing is since it is anonymous it will not clash with any globals and automatically goes out of scope when you are done. { ## Annon glob my $fh = do {local *FH }; # <---- Black magic here. ## Open and read open ($fh, "$File") || die("\nERROR: unable to read \"$File\" at \"" . (caller)[1] ."\" line ". (caller)[2] ."\n"); my @lines = <$fh>; ## Close and exit close($fh); } Learned this one from the Perl Journal. Graydon Dodson (606) 232-6483 grdodson@lexmark.com Lexmark International Inc. From rbowen at rcbowen.com Tue Nov 16 07:50:09 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting Message-ID: <38316111.5610A23F@rcbowen.com> I was going to try to make some posters a little earlier than usual this time, since we have a volunteer to speak, and I realized that I did not write down who volunteered to speak. Someone said that they would talk about writing modules, I think. Sorry, I have a mind like a steel sieve. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rbowen at rcbowen.com Tue Nov 16 08:29:01 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: <99111517493200.02787@localhost.localdomain> Message-ID: <38316A2D.E17F2C92@rcbowen.com> R Mullikin wrote: > > is this the list address? Yes, this is the correct address! Welcome aboard. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From repett0 at sac.uky.edu Tue Nov 16 11:13:54 1999 From: repett0 at sac.uky.edu (repett0@sac.uky.edu) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting In-Reply-To: <38316111.5610A23F@rcbowen.com> Message-ID: If you make posters or something, I can delever some to UKLUG, and also tell a few other people about the meeting. Ron UKLUG treasurer 7&7&7&7&7&7&7&7&7&7&7&7777777&77 On Tue, 16 Nov 1999, Rich Bowen wrote: > I was going to try to make some posters a little earlier than usual this > time, since we have a volunteer to speak, and I realized that I did not > write down who volunteered to speak. Someone said that they would talk > about writing modules, I think. Sorry, I have a mind like a steel sieve. > > Rich > -- > http://www.ApacheUnleashed.com/ > Lexington Perl Mongers - http://lexington.pm.org/ > PGP Key - http://www.rcbowen.com/pgp.txt > From hempy at ket.org Tue Nov 16 13:01:33 1999 From: hempy at ket.org (David Hempy) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting In-Reply-To: References: <38316111.5610A23F@rcbowen.com> Message-ID: <4.1.19991116140117.034a93d0@mail.ket.org> At 12:13 PM 11/16/1999 -0500, you wrote: > >If you make posters or something, I can delever some to UKLUG, and also >tell a few other people about the meeting. > >Ron >UKLUG treasurer I will send some to CKCS, via Paul Stackhouse. -dave -- David Hempy Internet Database Administrator Kentucky Educational Television From rich at mullikin.com Tue Nov 16 16:06:07 1999 From: rich at mullikin.com (R Mullikin) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: <38316A2D.E17F2C92@rcbowen.com> Message-ID: <99111617141102.03961@localhost.localdomain> I'm a total newbie to Perl, and I'm wondering if this might be a good application for Perl. The only thing I've done so far in Perl is a little program to clean up and format an IIS log file so I could read it. Anyway, would Perl be a good tool to use to take a file of comma-delimited data and spin it into a bunch of fixed-format web pages (by fixed format I mean that there's a bunch of static HTML and the data from the file goes in the same place on each page)? Also, are there any good repositories of 'code-snippets' which might keep one from constantly re-creating the wheel? Thanks, Richard On Tue, 16 Nov 1999, thus spake Rich Bowen: > R Mullikin wrote: > > > > is this the list address? > > Yes, this is the correct address! Welcome aboard. > > Rich > -- > http://www.ApacheUnleashed.com/ > Lexington Perl Mongers - http://lexington.pm.org/ > PGP Key - http://www.rcbowen.com/pgp.txt -- ============================================================================= Richard Mullikin www.horsedata.com Handicapper's Data Warehouse hdwinfo@horsedata.com ============================================================================= From sungo at earthling.net Tue Nov 16 19:16:48 1999 From: sungo at earthling.net (Matt Cashner) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting In-Reply-To: <4.1.19991116140117.034a93d0@mail.ket.org> Message-ID: wasnt it frank price who volunteered? smack me around frank if i got your name wrong or if you didnt actually volunteer. :) but that's what i seem to remember. --------------------- Matt Cashner sungo@earthling.net --------------------- "Every dark cloud has a silver lining, but lightning kills hundreds of people each year who try to find it." From rbowen at rcbowen.com Tue Nov 16 19:36:38 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: <38316A2D.E17F2C92@rcbowen.com> <99111617141102.03961@localhost.localdomain> Message-ID: <383206A6.CBFCEA47@rcbowen.com> R Mullikin wrote: > > I'm a total newbie to Perl, and I'm wondering if this might be a good > application for Perl. The only thing I've done so far in Perl is a > little program to clean up and format an IIS log file so I could read > it. > > Anyway, would Perl be a good tool to use to take a file of > comma-delimited data and spin it into a bunch of fixed-format web > pages (by fixed format I mean that there's a bunch of static HTML and > the data from the file goes in the same place on each page)? Perl would be absolutely ideal for such a thing. In fact, it was invented to do something not terribly unlike that. It was before the web and HTML, but the idea was similar - taking a bunch of data files, and spinning then into fixed-format reports. One module that would be really good for this would be the Text::Template module, which takes a static template file (could be HTML) and puts data into fixes places on that template. > Also, are there any good repositories of 'code-snippets' which might > keep one from constantly re-creating the wheel? Yes. It's called CPAN. http://www.cpan.org/ There is also a "scripts" section within CPAN that is good for snippets and whole functioning scripts. But the bulk of CPAN is modules, which give you additional functionality for doing stuff. Come to Perl Mongers next month, and you'll learn all about modules! Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rbowen at rcbowen.com Tue Nov 16 19:37:02 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting References: Message-ID: <383206BE.EF191F33@rcbowen.com> Matt Cashner wrote: > > wasnt it frank price who volunteered? smack me around frank if i got your > name wrong or if you didnt actually volunteer. :) but that's what i seem > to remember. If I put it on the poster, then he has to do it, right? ;-) Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rbowen at rcbowen.com Tue Nov 16 19:41:44 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: <38316A2D.E17F2C92@rcbowen.com> <99111617141102.03961@localhost.localdomain> <383206A6.CBFCEA47@rcbowen.com> Message-ID: <383207D8.4F1FCDD7@rcbowen.com> Rich Bowen wrote: > > > Also, are there any good repositories of 'code-snippets' which might > > keep one from constantly re-creating the wheel? > > Yes. It's called CPAN. http://www.cpan.org/ There is also a "scripts" > section within CPAN that is good for snippets and whole functioning > scripts. But the bulk of CPAN is modules, which give you additional > functionality for doing stuff. Come to Perl Mongers next month, and > you'll learn all about modules! Oh, yeah, and if you don't mind dropping a few dollars, there's also the Perl Cookbook, which is a cookbook of code snippets, suggestions, and recipes, that show you how to do little (and not-so-little) things in Perl. Very good book. Nathan Torkington and Tom Christiansen. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rich at mullikin.com Tue Nov 16 20:06:23 1999 From: rich at mullikin.com (R Mullikin) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test In-Reply-To: <383207D8.4F1FCDD7@rcbowen.com>; from Rich Bowen on Tue, Nov 16, 1999 at 08:41:44PM -0500 References: <38316A2D.E17F2C92@rcbowen.com> <99111617141102.03961@localhost.localdomain> <383206A6.CBFCEA47@rcbowen.com> <383207D8.4F1FCDD7@rcbowen.com> Message-ID: <19991116210623.A1234@mullikin.com> On Tue, Nov 16, 1999 at 08:41:44PM -0500, Thus spake Rich Bowen (rbowen@rcbowen.com): > Rich Bowen wrote: > > > > > Also, are there any good repositories of 'code-snippets' which might > > > keep one from constantly re-creating the wheel? > > > > Yes. It's called CPAN. http://www.cpan.org/ There is also a "scripts" > > section within CPAN that is good for snippets and whole functioning > > scripts. But the bulk of CPAN is modules, which give you additional > > functionality for doing stuff. Come to Perl Mongers next month, and > > you'll learn all about modules! > > Oh, yeah, and if you don't mind dropping a few dollars, there's also the > Perl Cookbook, which is a cookbook of code snippets, suggestions, and > recipes, that show you how to do little (and not-so-little) things in > Perl. Very good book. Nathan Torkington and Tom Christiansen. > > Rich > -- > http://www.ApacheUnleashed.com/ > Lexington Perl Mongers - http://lexington.pm.org/ > PGP Key - http://www.rcbowen.com/pgp.txt I already have that, as well as Programming Perl. Haven't read them yet, but did use them and some stuff from a big fat Redhat 6.0 Unleashed book to put together my little program that looks at IIS logs. -- ===================================================== Richard Mullikin hdwinfo@horsedata.com Handicapper's Data Warehouse www.horsedata.com ===================================================== From rich at mullikin.com Tue Nov 16 20:08:51 1999 From: rich at mullikin.com (R Mullikin) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test In-Reply-To: <383206A6.CBFCEA47@rcbowen.com>; from Rich Bowen on Tue, Nov 16, 1999 at 08:36:38PM -0500 References: <38316A2D.E17F2C92@rcbowen.com> <99111617141102.03961@localhost.localdomain> <383206A6.CBFCEA47@rcbowen.com> Message-ID: <19991116210851.B1234@mullikin.com> On Tue, Nov 16, 1999 at 08:36:38PM -0500, Thus spake Rich Bowen (rbowen@rcbowen.com): > R Mullikin wrote: > > > > I'm a total newbie to Perl, and I'm wondering if this might be a good > > application for Perl. The only thing I've done so far in Perl is a > > little program to clean up and format an IIS log file so I could read > > it. > > > > Anyway, would Perl be a good tool to use to take a file of > > comma-delimited data and spin it into a bunch of fixed-format web > > pages (by fixed format I mean that there's a bunch of static HTML and > > the data from the file goes in the same place on each page)? > > Perl would be absolutely ideal for such a thing. In fact, it was > invented to do something not terribly unlike that. It was before the web > and HTML, but the idea was similar - taking a bunch of data files, and > spinning then into fixed-format reports. > > One module that would be really good for this would be the > Text::Template module, which takes a static template file (could be > HTML) and puts data into fixes places on that template. > > > Also, are there any good repositories of 'code-snippets' which might > > keep one from constantly re-creating the wheel? > > Yes. It's called CPAN. http://www.cpan.org/ There is also a "scripts" > section within CPAN that is good for snippets and whole functioning > scripts. But the bulk of CPAN is modules, which give you additional > functionality for doing stuff. Come to Perl Mongers next month, and > you'll learn all about modules! > > Rich > -- > http://www.ApacheUnleashed.com/ > Lexington Perl Mongers - http://lexington.pm.org/ > PGP Key - http://www.rcbowen.com/pgp.txt How would I know if I have the Test::Template module or not? I run RH 6.0 at home on a DEC Alpha, and I installed Perl on several of our Dell/NT machines at the office (along with VIM). Thanks for the help. Richard -- ===================================================== Richard Mullikin hdwinfo@horsedata.com Handicapper's Data Warehouse www.horsedata.com ===================================================== From rbowen at rcbowen.com Tue Nov 16 21:28:44 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: <38316A2D.E17F2C92@rcbowen.com> <99111617141102.03961@localhost.localdomain> <383206A6.CBFCEA47@rcbowen.com> <383207D8.4F1FCDD7@rcbowen.com> <19991116210623.A1234@mullikin.com> Message-ID: <383220EC.C4CE0F2B@rcbowen.com> > I already have that, as well as Programming Perl. Haven't read > them yet, but did use them and some stuff from a big fat Redhat > 6.0 Unleashed book to put together my little program that looks > at IIS logs. You'll be pleased to know that one of our new Lexington.pm members is the primary author of that tome, and that another Lexington.pm member wrote two chapters for that tome. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From dpitts at mk.net Tue Nov 16 22:21:51 1999 From: dpitts at mk.net (David Pitts) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: <38316A2D.E17F2C92@rcbowen.com> <99111617141102.03961@localhost.localdomain> <383206A6.CBFCEA47@rcbowen.com> <383207D8.4F1FCDD7@rcbowen.com> <19991116210623.A1234@mullikin.com> Message-ID: <008e01bf30b3$46287900$8101a8c0@adverb.com> > but did use them and some stuff from a big fat Redhat > 6.0 Unleashed book to put together my little program that looks > at IIS logs. Great book!! From sungo at earthling.net Tue Nov 16 22:14:39 1999 From: sungo at earthling.net (Matt Cashner) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test In-Reply-To: <008e01bf30b3$46287900$8101a8c0@adverb.com> Message-ID: On Tue, 16 Nov 1999, David Pitts wrote: > > but did use them and some stuff from a big fat Redhat > > 6.0 Unleashed book to put together my little program that looks > > at IIS logs. > > Great book!! i smell a biased opinion! (though actually it is a great book :) --------------------- Matt Cashner sungo@earthling.net --------------------- "That which does not kill me postpones the inevitable." From dpitts at mk.net Tue Nov 16 22:57:45 1999 From: dpitts at mk.net (David Pitts) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test References: Message-ID: <00ce01bf30b8$4a1d1980$8101a8c0@adverb.com> > > i smell a biased opinion! > > (though actually it is a great book :) I have no problem with this statement! Moose From fprice at mis.net Wed Nov 17 10:33:25 1999 From: fprice at mis.net (Frank Price) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: test In-Reply-To: <19991116210851.B1234@mullikin.com> Message-ID: On Tue, 16 Nov 1999, R Mullikin wrote: # How would I know if I have the Test::Template module or not? # I run RH 6.0 at home on a DEC Alpha, and I installed Perl on # several of our Dell/NT machines at the office (along with VIM). Mmm, vim, so delicious... I don't know if this will work under NT, but on *nix what I do to test for a module is perl -MText::Template or perl -e 'use Text::Template; print "";' Both these will try to load the module, and print an error if it can't find it in the "expected places." HTH, -Frank. ____ ____ Frank Price Unix sysadmin, Perl fprice@mis.net & Web Programming From fprice at mis.net Wed Nov 17 10:39:33 1999 From: fprice at mis.net (Frank Price) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting In-Reply-To: <383206BE.EF191F33@rcbowen.com> Message-ID: On Tue, 16 Nov 1999, Rich Bowen wrote: # Matt Cashner wrote: # > # > wasnt it frank price who volunteered? smack me around frank if i got your # > name wrong or if you didnt actually volunteer. :) but that's what i seem # > to remember. # # If I put it on the poster, then he has to do it, right? ;-) Um, yes. But he will anyway, if he gets off his lazy butt and comes up with something to say :-) What's the date on this meeting, anyway? -Frank. ____ ____ Frank Price Unix sysadmin, Perl fprice@mis.net & Web Programming From rbowen at rcbowen.com Wed Nov 17 10:40:20 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: December meeting References: Message-ID: <3832DA74.58F5AAD6@rcbowen.com> Frank Price wrote: > > On Tue, 16 Nov 1999, Rich Bowen wrote: > > # Matt Cashner wrote: > # > > # > wasnt it frank price who volunteered? smack me around frank if i got your > # > name wrong or if you didnt actually volunteer. :) but that's what i seem > # > to remember. > # > # If I put it on the poster, then he has to do it, right? ;-) > > Um, yes. But he will anyway, if he gets off his lazy butt and comes > up with something to say :-) > > What's the date on this meeting, anyway? 2nd monday of every month, which is the 13th of December. 6pm - 8pm. I'll try to get posters made this evening. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rbowen at rcbowen.com Wed Nov 17 20:26:06 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: Administrative note Message-ID: <383363BE.B1B5D5B4@rcbowen.com> It appears that if your subject line contains the word "help", this mailing list bounces your message. I am not sure why that is the case, but I've seen this a few times now, and the bounce message says: Subject: BOUNCE lexington-pm-list@pm.org: Admin request: /^subject:\s*help\b/i This seems a little strange to me, but I suppose it is part of their effort to reduce spam or something. So, Dave, you might want to resend your message, and everyone might want to keep this in mind when creting subject lines. At least until I figure out why the heck they would be doing something like this. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From hempy at ket.org Thu Nov 18 10:21:28 1999 From: hempy at ket.org (David Hempy) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: H*lp with undef? Message-ID: <4.1.19991118112106.03bd3bc0@mail.ket.org> Okay, I'm a bit stumped here regarding very simple use of a hash. I want to say: $some_field = $in{"myfield"}; # Line 51 $foo = "Their field has: " . $in{$some_field}; # Line 52 Problem is, if there is no $in{"myfield"}, then $some_field is undef, and I get: "Use of uninitialized value at mailform.bat line 52." I do not know in advance whether there will be "myfield" or not...it is optional. I had expected the . operator to quietly ignore my attempt to concatenate a string and undef, as that seems like a pretty perlish sort of thing from what I've seen. I *think* the problem is trying to use . and undef together...I don't think searching for an undef key in the hash is the problem, but I'm not crystal clear on that one. The cleanest solution I've come across so far is: $foo = "Their field has: " . $in{$some_field} if defined($some_field); This still seems pretty cludgey, and not nearly as graceful as the scripts Rich and Nat share with us. There are a dozen places I use optional fields in this CGI script, and would much rather just use them blindly regardless of whether they are undef or not, instead of testing their values all over the place. Can I change the assignment of $some_field so it gets a more benign value that won't cause errors later on and won't require testing? Am I missing something here? Am I trying to push a rope up a hill? Any suggestions? -dave -- David Hempy Internet Database Administrator Kentucky Educational Television From fireston at lexmark.com Thu Nov 18 10:40:58 1999 From: fireston at lexmark.com (Mik Firestone) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: H*lp with undef? In-Reply-To: <4.1.19991118112106.03bd3bc0@mail.ket.org> Message-ID: <199911181641.LAA28125@interlock2.lexmark.com> $in{' '} = ''; # Init your constant $some_field = $in{"myfield"} || ' '; # Line 51 $foo = "Their field has: " . $in{$some_field}; # Line 52 should take care of this problem. Yes, the purists will likely object. HTH, Mik On Thu, 18 Nov 1999, David Hempy wrote: > > Okay, I'm a bit stumped here regarding very simple use of a hash. I want > to say: > > $some_field = $in{"myfield"}; # Line 51 > $foo = "Their field has: " . $in{$some_field}; # Line 52 > > Problem is, if there is no $in{"myfield"}, then $some_field is undef, and I > get: > > "Use of uninitialized value at mailform.bat line 52." > > I do not know in advance whether there will be "myfield" or not...it is > optional. I had expected the . operator to quietly ignore my attempt to > concatenate a string and undef, as that seems like a pretty perlish sort of > thing from what I've seen. > > I *think* the problem is trying to use . and undef together...I don't think > searching for an undef key in the hash is the problem, but I'm not crystal > clear on that one. > > > > The cleanest solution I've come across so far is: > > $foo = "Their field has: " . $in{$some_field} if defined($some_field); > > This still seems pretty cludgey, and not nearly as graceful as the scripts > Rich and Nat share with us. There are a dozen places I use optional fields > in this CGI script, and would much rather just use them blindly regardless > of whether they are undef or not, instead of testing their values all over > the place. > > Can I change the assignment of $some_field so it gets a more benign value > that won't cause errors later on and won't require testing? > > > Am I missing something here? Am I trying to push a rope up a hill? Any > suggestions? > > > -dave > > > > -- > David Hempy > Internet Database Administrator > Kentucky Educational Television > > -- Mik Firestone fireston@lexmark.com When I become an Evil Overlord: I will be secure in my superiority. Therefore, I will feel no need to prove it by leaving clues in the form of riddles or leaving my weaker enemies alive to show they pose no threat. From rbowen at rcbowen.com Thu Nov 18 12:44:34 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: Poster Message-ID: <38344912.FE34527C@rcbowen.com> For whatever reason, the password on the lexingtom.pm.org account has been changed, and I can't get in. Until this is resolved, you can get the poster at http://www.rcbowen.com/lpm_poster.gif I took Joe's fine artistic advice, so hopefully this is better than last time. And I checked the date 3 times, so I'm pretty sure I got it right this time around. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From fprice at mis.net Thu Nov 18 19:36:00 1999 From: fprice at mis.net (Frank Price) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: H*lp with undef? In-Reply-To: <4.1.19991118112106.03bd3bc0@mail.ket.org> Message-ID: On Thu, 18 Nov 1999, David Hempy wrote: # Okay, I'm a bit stumped here regarding very simple use of a hash. I want # to say: # # $some_field = $in{"myfield"}; # Line 51 # $foo = "Their field has: " . $in{$some_field}; # Line 52 Hmmm... I'm not sure I understand this. Line 51 assigns the value of $in{'myfield'} to a scalar. So $some_field contains either a simple scalar value, or a reference. But Line 52 isn't dereferencing the value ... I'm not sure I understand what this is trying to do... # Problem is, if there is no $in{"myfield"}, then $some_field is undef, and I # get: # # "Use of uninitialized value at mailform.bat line 52." # # I do not know in advance whether there will be "myfield" or not...it is # optional. I had expected the . operator to quietly ignore my attempt to # concatenate a string and undef, as that seems like a pretty perlish sort of # thing from what I've seen. Do you still get this if you run without the -w flag? I would approach this from the point where the hash key and value gets put in. That is, from whatever section it is where you find out about 'myfield' (presumably it's not from iterating over the keys of %in !), test $in{'myfield'}: $in{'myfield'} = "no value" unless defined $in{'myfield'}; Alternately, you could do this if you want to keep $in{'myfield'} undefined: $somefield = $in{'myfield'} or ""; # The cleanest solution I've come across so far is: # # $foo = "Their field has: " . $in{$some_field} if defined($some_field); # # This still seems pretty cludgey, and not nearly as graceful as the scripts # Rich and Nat share with us. There are a dozen places I use optional fields # in this CGI script, and would much rather just use them blindly regardless # of whether they are undef or not, instead of testing their values all over # the place. See, I would think you would want to do something like this, to just print out the keys and values that /are/ defined and not worry about those that aren't: foreach $key (sort keys %in) { print "Their field has: $in{$key}\n"; } But I probably don't understand the problem very well :-) -Frank. ____ ____ Frank Price Unix sysadmin, Perl fprice@mis.net & Web Programming From rbowen at rcbowen.com Sat Nov 27 15:38:31 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: "" interpolates method calls? Message-ID: <38404F57.8103E950@rcbowen.com> I'm really confused, and I've been banging my head on this one for about an hour, so perhaps I'm looking right at the answer. Usually, the fastest way to find an answer is to publically humiliate myself by asking a stupid question - I invariably figure out the answer about 3 seconds after pressing "Send." Anyways, here's the dilemma. I have something like this: $table = $foo->method $sth = $dbh->prepare("select * from $table order by date_time desc"); And that works. $foo is a object from the Baz::Mumble class, and method is a method in that class. Pretty straight forward. The problem is that when I do: $sth = $dbh->prepare("select * from $foo->method order by date_time desc"); I get: DBD::mysql::st execute failed: You have an error in your SQL syntax near '::Mumble =HASH(0x8204798)->method Which seems to mean to me that $foo is getting interpolated in the "", but $foo->method is not. How do I get $foo->method to get correctly called inside of ""? More specifically, without getting DBI in the way, I have: print $foo->method; # Produced the expected result print "$foo->method"; # Produced "::Mumble=HASH(0x8204798)->method" TIA, and I'll let you know when I figure out the answer in 3 seconds. I hope. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From sml at ns.zfx.com Sat Nov 27 19:56:29 1999 From: sml at ns.zfx.com (Steve Lane (ZFX)) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: "" interpolates method calls? In-Reply-To: <38404F57.8103E950@rcbowen.com> Message-ID: On Sat, 27 Nov 1999, Rich Bowen wrote: > Which seems to mean to me that $foo is getting interpolated in the "", > but $foo->method is not. How do I get $foo->method to get correctly > called inside of ""? strictly speaking, "$foo->method" -is- getting correctly interpreted, because method calls simply do not get interpolated inside "". you can always do the silly "... @{[$foo->method]} ..." if you really want the method call to be evaluated within the "". -- Steve Lane From rbowen at rcbowen.com Sun Nov 28 09:50:07 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: "" interpolates method calls? References: Message-ID: <38414F2F.F37870@rcbowen.com> "Steve Lane (ZFX)" wrote: > > On Sat, 27 Nov 1999, Rich Bowen wrote: > > Which seems to mean to me that $foo is getting interpolated in the "", > > but $foo->method is not. How do I get $foo->method to get correctly > > called inside of ""? > > strictly speaking, "$foo->method" -is- getting correctly > interpreted, because method calls simply do not get > interpolated inside "". Yes, when I finally read the docs correctly, I saw this. Irritating, but that's what I get for ignoring the documentation. > you can always do the silly "... @{[$foo->method]} ..." > if you really want the method call to be evaluated > within the "". That is pretty silly looking, isn't it? But for some reason, I'm having trouble getting DBI to understand queries that have string concatenation in them. Could be I was just working on it for too long at a stretch, and it will work correctly this time. Thanks for the info. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From rbowen at rcbowen.com Sun Nov 28 15:42:57 1999 From: rbowen at rcbowen.com (Rich Bowen) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: "" interpolates method calls? References: <3.0.6.16.19991127172958.38c75e94@pop.uky.edu> Message-ID: <3841A1E1.4D5EF729@rcbowen.com> Michael Wallace wrote: > > I'm working on a database project right now and I have seen some similar > stuff happen. I don't know why $foo->method isn't interpolated, but I > think I got around it just by doing: > > $sth = $dbh->prepare("select * from " . $foo->method . > " order by date_time desc"); Important note there. This did not work for me at first, because I was being a dodo-head (technical term) and had: $sth = $dbh->prepare("select * from" . $foo->method . "order by date_time desc"); Note lack of spaces before and after $foo->method, which causes things to break. Languages that care about whitespace irritate me! > That I wish I knew. When you figure it out in three seconds, I think all > of us would like to know. :) Well the answer was, as usual, to RTFM before spending an hour trying to figure it out. And, the corollary to that is, if something appears amazingly complicated, and you're working with Perl, you are clearly thinking about it wrong. Easy things easy, hard things possible. I just get so wrapped up in trying to solve things like this that I waste entire afternoons on it, which really aggravates me. Rich -- http://www.ApacheUnleashed.com/ Lexington Perl Mongers - http://lexington.pm.org/ PGP Key - http://www.rcbowen.com/pgp.txt From oneiros at dcr.net Sun Nov 28 15:50:35 1999 From: oneiros at dcr.net (Joe Hourcle) Date: Thu Aug 5 00:06:27 2004 Subject: LPM: "" interpolates method calls? In-Reply-To: <3841A1E1.4D5EF729@rcbowen.com> Message-ID: On Sun, 28 Nov 1999, Rich Bowen wrote: > $sth = $dbh->prepare("select * from" . $foo->method . > "order by date_time desc"); > > Note lack of spaces before and after $foo->method, which causes things > to break. Languages that care about whitespace irritate me! It's things like this, especially when building complex SQL queries, where it comes in handy to put the string in a variable first, jsut so you can access it when debugging to see if there's something wrong with it. (of course, my realization when I was doing stuff like this was in VBA, which will only show so many characters of a string, so I had to have it open a form, and place the string in the field, and keep *@$#%^ing switching back and forth, etc.) -Joe