From brian at ingerson.com Sun Oct 1 03:16:51 2000 From: brian at ingerson.com (Brian Ingerson) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Perligata talk References: <20000929180010.A2247@ilmd> <20000930231001.A1038@timji.consultix.wa.com> Message-ID: <39D6F2F3.74771C5F@ingerson.com> Tim Maher/CONSULTIX wrote: > There's a > chance we'll also have on hand a "mystery guest" from the PPGP > (Peripatetic Perl Guru Pool), to handle queries and spout perls of > wisdom ($initials =~ [nmr][jl]?[tds]). There's also a good chance of meeting ActiveState Perl luminaries of the form $initials =~ /[gad:]-?[hats)]/; This is one not to miss. Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Sun Oct 1 23:35:17 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Perl tutorial: the grep, map and sort functions References: <20000929180010.A2247@ilmd> <20000930231001.A1038@timji.consultix.wa.com> <39D6F2F3.74771C5F@ingerson.com> Message-ID: <051801c02c2a$3290e8a0$790ff93f@adcom133> A revised version of the slides from my presentation at the last SPUG meeting is now available at http://www.unixscripts.com/rayco/support/perl_tutor.html (That's .../perl_tutor.html, if your email client is underlining the URL.) I invite suggestions on this doc, especially on the discussion of the linguistic origins of the term "Orcish maneuver", which is mostly speculative. Richard.Anderson@raycosoft.com www.zipcon.net/~starfire/home (personal) www.raycosoft.com (corporate) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Sun Oct 1 16:46:57 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Perl tutorial: the grep, map and sort functions In-Reply-To: <051801c02c2a$3290e8a0$790ff93f@adcom133>; from Richard Anderson on Sun, Oct 01, 2000 at 09:35:17PM -0700 References: <20000929180010.A2247@ilmd> <20000930231001.A1038@timji.consultix.wa.com> <39D6F2F3.74771C5F@ingerson.com> <051801c02c2a$3290e8a0$790ff93f@adcom133> Message-ID: <20001001214657.A7024@timji.consultix.wa.com> On Sun, Oct 01, 2000 at 09:35:17PM -0700, Richard Anderson wrote: > A revised version of the slides from my presentation at the last SPUG > meeting is now available at > http://www.unixscripts.com/rayco/support/perl_tutor.html (That's Thanks! > .../perl_tutor.html, if your email client is underlining the URL.) I invite > suggestions on this doc, especially on the discussion of the linguistic > origins of the term "Orcish maneuver", which is mostly speculative. No need to speculate on its origins; Joseph N. Hall says on p. 48 of his 1998 "Effective Perl Programming": . . . this is something I have nicknamed the "Orcish Maneuver" (The "or-cache" . . . Arrgh.) . . . It uses the little-known ||= operator. > Richard.Anderson@raycosoft.com -Tim *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 10/9: Adv OO-Perl/Parsing 10/16: Int. Perl 10/23 Perl Prog. | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Mon Oct 2 02:24:33 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: PHP contrax, Seattle Message-ID: <20001002072433.C7024@timji.consultix.wa.com> SPUGsters, I'm relaxing the usual posting requirements already by allowing a PHP-job post, and since I expect very few people to be interested I'm going to permit this posting without the usual details being included, on the expectation that few will miss them. -Tim ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== SPUG, I am writing to you as I understand that many PERL programmers are familiar with PHP scripting. We are looking for a programmer ASAP that can help us finish up our website/program. Please contact Steve Otto at this return address. Thank you. Steve *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 10/9: Adv OO-Perl/Parsing 10/16: Int. Perl 10/23 Perl Prog. | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From yaoxi.wu at attws.com Mon Oct 2 12:44:28 2000 From: yaoxi.wu at attws.com (Wu, Yaoxi) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script Message-ID: This thing is driving me crazy; I hope someone can enlighten me. Please look at the following short cgi script: #!/usr/bin/perl -wT use CGI; $cgi = new CGI; print $cgi->header("text/plain"); open(DB_FILE, "test.bib"); undef $/; $line=; close DB_FILE; #### the following was displayed o.k. ########## print "Any string.\n"; print $cgi->param('source_type'),"\n"; #### the following did not show up in the web browser window ### print "$line\n"; foreach $name ($cgi->param){ print "$name:\n"; foreach $value ($cgi-param($name)){ print " $values\n"; } } This simple script tries to display the content of a two-line text file, " test.bib", and the values of the parameters that the user input from a web page. I don't know why the statement, print "$line\n", displayed nothing, although when the script run off-line and was terminated with 'control-D', the file content was displayed. Also, why the values of the user-supplied parameters could not display in this "foreach" loop, but would display when printing individually? Thanks for any help. YW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From meonkeys at hotmail.com Mon Oct 2 15:44:46 2000 From: meonkeys at hotmail.com (Adam Monsen) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Re: generating output with a cgi script Message-ID: To get your version to work: A. Use the full pathname for the file. ie: open(DB_FILE, "/home/httpd/html/test.bib"); B. Looks like you have a couple of typos (no > after $cgi-, misspelled "$value") and an unnecessary foreach loop. Instead of: foreach $value ($cgi-param($name)) { print " $values\n"; } try this... print $cgi->param($name)."\n"; Here's some hints: 1. You don't need the second "foreach" loop, you're already iterating over all the CGI params (see "B"). 2. Always "use strict" (along with perl -w and -T if you need it), this helps to disallow some unsafe constructs (It would have noted that you never use "my", for instance). 3. Use "or die" with your "open(DB_FILE..." this is a key operation, and you need to know if it fails. 4. Process the file line by line rather than all at once. This scales better. Good Luck, Yaoxi! To the gurus: I would appreciate any hints/elucidations on my recommendations. Thanks! >From: "Wu, Yaoxi" To: "'spug-list@pm.org'" Subject: SPUG: generating output >with a cgi script Date: Mon, 2 Oct 2000 10:44:28 -0700 > > >This thing is driving me crazy; I hope someone can enlighten me. Please >look at the following short cgi script: > >#!/usr/bin/perl -wT use CGI; $cgi = new CGI; print >$cgi->header("text/plain"); open(DB_FILE, "test.bib"); undef $/; $line=; >close DB_FILE; > >#### the following was displayed o.k. ########## > >print "Any string.\n"; print $cgi->param('source_type'),"\n"; > >#### the following did not show up in the web browser window ### > >print "$line\n"; foreach $name ($cgi->param){ print "$name:\n"; foreach >$value ($cgi-param($name)){ print " $values\n"; } } > >This simple script tries to display the content of a two-line text file, " >test.bib", and the values of the parameters that the user input from a web >page. I don't know why the statement, print "$line\n", displayed nothing, >although when the script run off-line and was terminated with 'control-D', >the file content was displayed. Also, why the values of the user-supplied >parameters could not display in this "foreach" loop, but would display when >printing individually? Thanks for any help. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tuck at whistlingfish.net Mon Oct 2 16:14:05 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script In-Reply-To: Message-ID: <9110000.970521245@benzene> -- "Wu, Yaoxi" spake thusly: > #!/usr/bin/perl -wT > use CGI; > $cgi = new CGI; > print $cgi->header("text/plain"); > open(DB_FILE, "test.bib"); > undef $/; > $line=; > close DB_FILE; > > #### the following was displayed o.k. ########## > > print "Any string.\n"; > print $cgi->param('source_type'),"\n"; > > #### the following did not show up in the web browser window ### > > print "$line\n"; > foreach $name ($cgi->param){ > print "$name:\n"; > foreach $value ($cgi-param($name)){ > print " $values\n"; > } > } The first thing I noticed is that the foreach $value line has "$cgi-param($name)". I assume this a typo, and is correct in the script itself? If not, then it's likely the cause of that part of the problem. As for the DB_FILE not printing, I'm guessing it's a permission issue. You should always check the return value of system calls like that, as in: open(DB_FILE, "test.bib") or die "Couldn't open file 'test.bib' for reading: $!\n"; Hope this helps. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001002/fc670bdc/attachment.bin From yaoxi.wu at attws.com Mon Oct 2 16:40:46 2000 From: yaoxi.wu at attws.com (Wu, Yaoxi) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script Message-ID: Thank everyone for the suggestions and hints! With your help, I have fixed the problems and my script is working! Following one of suggestions, I wrote a function to display the error message on the web browser (a simple "die ..." statement would cause the server to display something like "an internal error ..." which was not very helpful), and found out that the "open file" failed. The problem was with the file permission. The script and the text file were owned by the same person and the text file could only be rwx'ed by the owner. This explains that why running the script off-line had no problem. My guess for it not to run under the web server is that the server was run by "nobody" who had no permission to read the file. Modifying the file permission solved the problem. Does this mean that every data file to be accessd by the server must be owned by "nobody" or "world-readable"? As someone suggested, the second problem was caused by typos. Sorry about that. The fact that the script run successfully off-line the first time made me wondering that the two problems had the same cause, probably misconfigured perl compiler or web server. By the way, does anyone know a debugger program available for perl? Something similar to DDD for C? Again, thank you all so much for the help! YW -----Original Message----- From: JP Montagnet [mailto:jope@n2h2.com] Sent: Monday, October 02, 2000 11:01 AM To: Wu, Yaoxi Subject: Re: SPUG: generating output with a cgi script On Mon, 2 Oct 2000, Wu, Yaoxi wrote: > This thing is driving me crazy; I hope someone can enlighten me. > Please look at the following short cgi script: > > #!/usr/bin/perl -wT > use CGI; > $cgi = new CGI; > print $cgi->header("text/plain"); > open(DB_FILE, "test.bib"); > undef $/; > $line=; > close DB_FILE; My guess is that your open() statement failed, because you specified the file relative to whatever the current directory is. When your script is running as a CGI scrpt, that very well may not be the same directory the script is in. Either fully qualify your file location, or add a chdir() prior to the open(). CHeckingthe return code from your open() is always a good idea too. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From meryll at is2inc.com Mon Oct 2 17:40:11 2000 From: meryll at is2inc.com (Meryll Larkin) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script References: Message-ID: <39D90ECB.8CC8D17C@is2inc.com> "Wu, Yaoxi" wrote: > > Modifying the file permission solved the > problem. Does this mean that every data file to be accessd by the server > must be owned by "nobody" or "world-readable"? > YES!!! > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ -- Meryll Larkin IS Squared, Inc. meryll@is2inc.com 3400 188th St SW suite 500 (425) 775-6495 Lynnwood WA 98037 Fax: (425) 774-8564 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dougb at scalar.org Mon Oct 2 19:07:08 2000 From: dougb at scalar.org (Doug Beaver) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script In-Reply-To: ; from yaoxi.wu@attws.com on Mon, Oct 02, 2000 at 02:40:46PM -0700 References: Message-ID: <20001002170708.C33038@scalar.org> On Mon, Oct 02, 2000 at 02:40:46PM -0700, Wu, Yaoxi wrote: > > Thank everyone for the suggestions and hints! With your help, I have > fixed the problems and my script is working! > By the way, does anyone know a debugger program available for perl? > Something similar to DDD for C? ddd does support perl, although I've never used it before. There is also a tk-based perl debugger named Devel::ptkdb, you can find it on CPAN. Perl also has a builtin command-line debugger that is similar to gdb, you enable it by passing the -d switch to perl. perldoc perldebug for more info, it's very useful. You should know how to use the command-line debugger even if you end up using ddd, you never know when you'll have to debug perl code running on a machine without X on it. Doug > Again, thank you all so much for the help! > > YW > > > -----Original Message----- > From: JP Montagnet [mailto:jope@n2h2.com] > Sent: Monday, October 02, 2000 11:01 AM > To: Wu, Yaoxi > Subject: Re: SPUG: generating output with a cgi script > > > On Mon, 2 Oct 2000, Wu, Yaoxi wrote: > > This thing is driving me crazy; I hope someone can enlighten me. > > Please look at the following short cgi script: > > > > #!/usr/bin/perl -wT > > use CGI; > > $cgi = new CGI; > > print $cgi->header("text/plain"); > > open(DB_FILE, "test.bib"); > > undef $/; > > $line=; > > close DB_FILE; > > My guess is that your open() statement failed, because you specified the > file relative to whatever the current directory is. When your script is > running as a CGI scrpt, that very well may not be the same directory the > script is in. Either fully qualify your file location, or add a chdir() > prior to the open(). CHeckingthe return code from your open() is always > a good idea too. > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > -- Smithers: I'm afraid we have a bad image, Sir. Market research shows people see you as somewhat of an ogre. Burns: I ought to club them and eat their bones! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Mon Oct 2 21:27:08 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script References: <39D90ECB.8CC8D17C@is2inc.com> Message-ID: <058d01c02ce2$08680640$790ff93f@adcom133> Not always. If your webmaster has configured the Apache setuid module, any CGI process the server starts will be owned by the owner of the CGI script. So the CGI process can read a file that is owned by your userid and has no group or world permissions. This is the way that most enlightened ISPs configure Apache. (But not NW Nexus, which is why I am no longer one of their customers.) Richard.Anderson@raycosoft.com www.zipcon.net/~starfire/home (personal) www.raycosoft.com (corporate) ----- Original Message ----- From: "Meryll Larkin" To: "Wu, Yaoxi" Cc: Sent: Monday, October 02, 2000 3:40 PM Subject: Re: SPUG: generating output with a cgi script > > > "Wu, Yaoxi" wrote: > > > > Modifying the file permission solved the > > problem. Does this mean that every data file to be accessd by the server > > must be owned by "nobody" or "world-readable"? > > > YES!!! > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > -- > Meryll Larkin IS Squared, Inc. > meryll@is2inc.com 3400 188th St SW suite 500 > (425) 775-6495 Lynnwood WA 98037 > Fax: (425) 774-8564 > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Mon Oct 2 21:31:17 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: generating output with a cgi script References: Message-ID: <058e01c02ce2$09c8f5d0$790ff93f@adcom133> Wu, Yaoxi wrote: > Following one of suggestions, I wrote a function to display the error > message on the web browser (a simple "die ..." statement would cause the > server to display something like "an internal error ..." which was not very > helpful), Better than writing a custom error handler is simply adding: use CGI::Carp 'fatalsToBrowser'; to your CGI script and calling die in the normal manner. Richard.Anderson@raycosoft.com www.zipcon.net/~starfire/home (personal) www.raycosoft.com (corporate) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Mon Oct 2 15:15:28 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: WANTED: New E-SPUG Emperor ! Message-ID: <20001002201528.A8470@timji.consultix.wa.com> SPUGsters, First of all, let's all give a big round of applause to young Ryan Erwin, for taking on the mantle of E-SPUG Emperor back when nobody else wanted it, and holding a series of successful meetings on the Eastside that helped bring Oriental SPUGsters together to revelry in SPUGery. !! Hip-Hip-Hooray !! Unfortunately, Ryan has become overloaded with enticing business opportunities, executive responsibilities, and stock options 8-}, and will no longer be serving as E-SPUG Emperor. So I'm soliciting volunteers to replace him. Anyone who has convenient access to the Eastside, has attended most of the E-SPUG meetings in the last year, is willing to lead meetings, arrange speakers, and otherwise coordinate all things E-SPUGish, please email me your credentials and plans for the group. Dave Patterson, our "landlord liaison", tells me that the Lucent meeting room remains booked through the remainder of the year, so I'm hoping to enthrone a new Emperor and resume regular activities with the upcoming October meeting. ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Tue Oct 3 05:56:34 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Wacky Aussie Programs in Latin, TONIGHT! Message-ID: <20001003105634.A1448@timji.consultix.wa.com> SPECIAL SPUGadelic EVENT: The Damian Returneth! This time, that wacky Aussie with the exotic imagination is going to teach us how to program Perl in that classical language of Popes and Roman ruins, everybody's favourite non-positional (inflected) language, LATIN! The talk is free, and the meeting runs from VII to IX PM. Be there, or miss out on a fun, yet educational, discussion of the infinite configurability of Perl. More details are presented below, and at the SPUG web site. -Tim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ** Lingua::Romana::Perligata ** Perl for the XXI-imus Century Dr. Damian Conway (damian@conway.org) Monash University, Australia Union Bank of CA Bldg., Seattle, WA Tuesday, October 3, 7-9pm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The great flaw of existing programming (and natural) languages is that word order matters, which makes it unnecessarily difficult to program (or talk) when drunk. You end up writing: push @casino's_money, @my_cash; instead of: push @my_cash, @casino's_money; Generally speaking, older natural languages rely less on word order. For example, in Latin the sentences "Puer dedit cani escam." and "Escam dedit puer cani." both mean "The boy gave the dog the food." In fact, the more usual word order would be "Reverse Polish", with the verb coming last: "Puer cani escam dedit." This flexibility is possible because Latin uses inflection to denote lexical roles, and that single fact allowed the Romans to build a vast empire despite their near-permanent state of inebriation. There is no reason that programming languages could not also make use of inflection rather than position to denote lexical roles, thereby allowing hackers to program in their natural -- inebriated -- state. >From that bar-room inspiration, it was only a small, slightly wobbly step to the Lingua::Romana::Perligata module: a Latin syntactic binding for Perl. No prior knowledge of the ancient Roman language will be assumed, but by the end of the talk (or at least by the end of the after-party) the following program will make perfect sense: maximum inquementum tum biguttam tum stadium egresso scribe. vestibulo perlegementum da meo maximo . maximum tum novumversum egresso scribe. da duo tum maximum conscribementa meis listis. dum damentum nexto listis decapitamentum fac sic lista sic hoc tum nextum recidementum cis vannementa listis da. next tum biguttam tum nextum tum novumversum scribe egresso. cis - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No, he's not kidding, or crazy (well, maybe a TAD crazy, but in a NICE way!). He's just a mild mannered computer professor with a special talent for couching inspirational talks on Perl in a uniquely entertaining, and unusual, style. This time, he'll be using a classical language as the basis for his presentation, in an attempt to create a more classy ambiance than he typically achieves with his more customary Klingon-language presentations. See the SPUG web site, and follow links from there, to get more information about his contributions to Perl and the many awards they've earned for him. Price and Location Admission is free and open to the general public. Attendees are encouraged to arrive at the Union Bank of California building's 5th & Madison door by 6:45pm, which might be locked at other times. (See the SPUG web-site for more details.) Parking We recommend avoiding the parking lot below the Union Bank building, due to the very hefty fee you'll be assessed if you leave after 9pm. There are plenty of other parking garages in the vicinity that are more affordable, and some on-street parking too. Pre/Post-Meeting Gathering Place Come and pass the pre-meeting time with other SPUGsters at the Rock Bottom brewpub, at 1333 5th Ave., (206) 623-3070, in downtown Seattle. Look to your left as you enter, near the bar or pool table, for bizarre yet strangely appealing characters wielding laptops and hearty ales. If you want to eat dinner there, try to arrive by 6:10pm, because you'll need to leave for the meeting place by 6:40pm. For more information, including driving directions and street addresses, see http://www.halcyon.com/spug/. ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From rathmore at bb12.betterbox.net Tue Oct 3 13:11:27 2000 From: rathmore at bb12.betterbox.net (rathmore@bb12.betterbox.net) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: stat command in NT Message-ID: Greetings, SPUGers! # End Lurker Mode How does one go about getting the timestamp on files in the NT world? I've written a quick script almost straight out of the Cook Book that works great on Unix but not at all on NT (except on . and ..). Take a look: use Time::Local; opendir (DIR, $somedir) or die "can't open $somedir: $!"; while (defined($sourcefile = readdir(DIR))) { ($access, $modify, $create) = (stat($sourcefile))[8..10]; print "$sourcefile : "; print "$access : $modify : $create\n"; } closedir(DIR); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ced at carios2.ca.boeing.com Tue Oct 3 17:11:38 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: stat command in NT Message-ID: <200010032211.PAA29617@carios2.ca.boeing.com> > How does one go about getting the timestamp on files in the NT world? I've > written a quick script almost straight out of the Cook Book that works > great on Unix but not at all on NT (except on . and ..). Take a look: > use Time::Local; > opendir (DIR, $somedir) or die "can't open $somedir: $!"; > ($access, $modify, $create) = (stat($sourcefile))[8..10]; > print "$sourcefile : "; > print "$access : $modify : $create\n"; > } .closedir(DIR); Normally, you need the directory pre-pended unless the program itself also runs in the same directory. opendir (DIR, $somedir) or die "can't open $somedir: $!"; while (defined($sourcefile = readdir(DIR))) { ($access, $modify, $create) = (stat("$somedir/$sourcefile"))[8..10]; Perhaps you were in the right place at the right time when you ran on Unix :) Rgds, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Thu Oct 5 10:54:59 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and Message-ID: <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com> I'm working on a little web automation routine and I've used HTML::LinkExtor to extract the links from a web page, then I'm processing each of those links. What I'd like to know is if there's some easy way that I could get the original text that accompanied that link. e.g., this text here I want . sub link_scan { # input is $url, output is a list of links found at that URL my $url = shift; my @linklist; my @ziplist; # retrieve HTML doc at URL my $ua = new LWP::UserAgent; my $request = new HTTP::Request('GET', $url); my $response = $ua->request($request); my $body = $response->content; my $base = $response->base; # scan HTML doc for other URLS my $link_parser = HTML::LinkExtor->new(); $link_parser->parse($body); my @parsed = $link_parser->links; foreach my $link (@parsed) { my $tag = $link->[0]; if (($tag eq "a") or ($tag eq "A")) { my $text = $link_parser->get_trimmed_text my $new_url = new URI::URL $link->[2]; my $full_url = $new_url->abs($url); chomp $full_url; unless (already_processed($full_url)) {push @linklist, $full_url;} } } return @linklist; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From rush at citylinq.com Thu Oct 5 11:30:27 2000 From: rush at citylinq.com (Rush Family) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and In-Reply-To: <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com> Message-ID: Although I do not have it in front of me to check, I believe this exact problem is solved in the Perl Cookbook from O'Reilly. -----Original Message----- From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of Todd Wells Sent: Thursday, October 05, 2000 8:55 AM To: 'SPUG' Subject: SPUG: extracting text between and I'm working on a little web automation routine and I've used HTML::LinkExtor to extract the links from a web page, then I'm processing each of those links. What I'd like to know is if there's some easy way that I could get the original text that accompanied that link. e.g., this text here I want . sub link_scan { # input is $url, output is a list of links found at that URL my $url = shift; my @linklist; my @ziplist; # retrieve HTML doc at URL my $ua = new LWP::UserAgent; my $request = new HTTP::Request('GET', $url); my $response = $ua->request($request); my $body = $response->content; my $base = $response->base; # scan HTML doc for other URLS my $link_parser = HTML::LinkExtor->new(); $link_parser->parse($body); my @parsed = $link_parser->links; foreach my $link (@parsed) { my $tag = $link->[0]; if (($tag eq "a") or ($tag eq "A")) { my $text = $link_parser->get_trimmed_text my $new_url = new URI::URL $link->[2]; my $full_url = $new_url->abs($url); chomp $full_url; unless (already_processed($full_url)) {push @linklist, $full_url;} } } return @linklist; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Thu Oct 5 11:47:36 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and Message-ID: <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> I looked in the Cookbook, it has a recipe to extract the actual links (which you'll see I'm doing in my code below), but I can't tell how to get the text between the tags -- unless I'm looking at it incorrectly. this is the text I actually want -----Original Message----- From: Rush Family [mailto:rush@citylinq.com] Sent: Thursday, October 05, 2000 9:30 AM To: Todd Wells; 'SPUG' Subject: RE: SPUG: extracting text between and Although I do not have it in front of me to check, I believe this exact problem is solved in the Perl Cookbook from O'Reilly. -----Original Message----- From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of Todd Wells Sent: Thursday, October 05, 2000 8:55 AM To: 'SPUG' Subject: SPUG: extracting text between and I'm working on a little web automation routine and I've used HTML::LinkExtor to extract the links from a web page, then I'm processing each of those links. What I'd like to know is if there's some easy way that I could get the original text that accompanied that link. e.g., this text here I want . sub link_scan { # input is $url, output is a list of links found at that URL my $url = shift; my @linklist; my @ziplist; # retrieve HTML doc at URL my $ua = new LWP::UserAgent; my $request = new HTTP::Request('GET', $url); my $response = $ua->request($request); my $body = $response->content; my $base = $response->base; # scan HTML doc for other URLS my $link_parser = HTML::LinkExtor->new(); $link_parser->parse($body); my @parsed = $link_parser->links; foreach my $link (@parsed) { my $tag = $link->[0]; if (($tag eq "a") or ($tag eq "A")) { my $text = $link_parser->get_trimmed_text my $new_url = new URI::URL $link->[2]; my $full_url = $new_url->abs($url); chomp $full_url; unless (already_processed($full_url)) {push @linklist, $full_url;} } } return @linklist; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From cwilkes at singingfish.com Thu Oct 5 12:36:09 2000 From: cwilkes at singingfish.com (Chris Wilkes) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Auto-vivification question In-Reply-To: <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> Message-ID: After gaining some insight at the last SPUG meeting on why this feature exists, I took up Mark-Jason's suggestion to do something about it. I decided to just look into getting around this issue in perl as I don't know C and it would take me forever to even find the right section in the perl source. My little trick involves copying the hash to a temporary variable and then doing the exists tests on it. No brain surgery here. It works for multi level hashes, but not for arrays of hashes or other complex data structures. Let me know if this looks correct and how I can make this more seemless. I don't mind calling the subroutine exists_nav() but I don't like the way I specify the keys to look at. Chris #!/usr/bin/perl use strict; my ($ref, $retcode); undef $ref; if (exists $ref->{"Some key"}) { } print "'$ref'\n"; # prints hash -- this is bad undef $ref; $retcode = exists_nav($ref, "Some key", "key 2"); print ( ($retcode) ? "exists\n" : "does not exist\n"); print "'$ref'\n"; # prints nothing undef $ref; $ref->{"Some key"}{"key 2"} = 1; $retcode = exists_nav($ref, "Some key", "key 2"); print ( ($retcode) ? "exists\n" : "does not exist\n"); print "'$ref'\n"; # prints HASH as it does exist undef $ref->{"Some key"}{"key 2"}; # not sure if this is right $retcode = exists_nav($ref, "Some key", "key 2"); print ( ($retcode) ? "exists\n" : "does not exist\n"); print "'$ref'\n"; # still prints hash, is this a problem? sub exists_nav { my ($a, @keys) = @_; my $b = $a; foreach (@keys) { return 0 unless (exists($b->{$_})); $b = $b->{$_}; } return 1; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tuck at whistlingfish.net Thu Oct 5 13:04:35 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and In-Reply-To: <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com> Message-ID: <12920000.970769075@flashingchance.whistlingfish.net> -- Todd Wells spake thusly: > I'm working on a little web automation routine and I've used > HTML::LinkExtor to extract the links from a web page, then I'm > processing each of those links. > > What I'd like to know is if there's some easy way that I could get the > original text that accompanied that link. e.g., "http://thislink"> this text here I want . You could do this with a simple regex. It ignores the structure of the document, but if you don't mind that then this should work: while ($html =~ /<[aA]\b[^>]*>([^<]*)/g) { push @linklist, $1; } You could also expand this a bit to pull the href out, if you so chose. If you want to continue using a parser like HTML::LinkExtor, and that one doesn't do what you want, it seems like you should look at using a different parser (HTML::Parser, for instance, which it derives from). Alternately you could change HTML::LinkExtor and submit your patch to the package maintainer. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001005/ca50c97a/attachment.bin From teccbk1 at sdc.cs.boeing.com Thu Oct 5 12:58:34 2000 From: teccbk1 at sdc.cs.boeing.com (Chuck Keagle) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and In-Reply-To: <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> (message from Todd Wells on Thu, 5 Oct 2000 09:47:36 -0700) Message-ID: <200010051758.KAA51415@denali.sdc.cs.boeing.com> Now I'm new with Perl (just had Dr. Tim's beginner class a couple weeks ago), but would a pattern match do the trick? m| ([\w ]*)| and $text = $1; If I'm way off base, please don't chastise me too harshly. -- (fixed width font) //\\ __________________________ \\ Chuck Keagle \\ .__=.\\ chuck.keagle@boeing.com \____ ,' H-D \-\<) Shared Services Group \ \______.,(_______/_:\ (425) 865-5394 |==.\______// # /# #\ || : \____ Fax: (425) 865-2221 '\\\ =''=//|_|##(O)##|| `./\---. M/S 7J-04 _____________ /\ / ,`--'./# ======='//, //.\ . \ _______ \ \_(_:_@O__)_///<_>O//// ( (@O ) ) _____ \_____________/======'O' \ `-' / __`-----'__________________`---'___ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Oct 5 06:09:14 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and Message-ID: <20001005110914.B2609@timji.consultix.wa.com> This might be the second time you see this and if so, I apologize 8-} (I may have responded only to the author in the first transmission.) -Tim Date: Thu, 5 Oct 2000 10:42:21 +0000 From: Tim Maher/CONSULTIX To: Todd Wells Subject: Re: SPUG: extracting text between and X-Mailer: Mutt 0.95.1i In-Reply-To: <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com>; from Todd Wells on Thu, Oct 05, 2000 at 08:54:59AM -0700 On Thu, Oct 05, 2000 at 08:54:59AM -0700, Todd Wells wrote: > I'm working on a little web automation routine and I've used HTML::LinkExtor > to extract the links from a web page, then I'm processing each of those > links. > > What I'd like to know is if there's some easy way that I could get the > original text that accompanied that link. e.g., "http://thislink"> this text here I want . You need to "Use Damian" 8-) ! His Text::Balanced module has a method called extract_tagged() that will find and parse your anchor tags and return each part in a different list element. For example: $ cat extract #! /usr/bin/perl -w use Text::Balanced 'extract_tagged'; $_= ' this text here I want MORE STUFF'; $skip=undef; ($parts{whole_match}, $parts{remnants}, $parts{skipover}, $parts{first_tag}, $parts{enclosed}, $parts{last_tag}) = extract_tagged($_,undef,undef,$skip); print map "$_\t=>'$parts{$_}'\n", sort keys %parts; $ ./extract enclosed =>' this text here I want ' first_tag =>'' last_tag =>'' remnants =>' MORE STUFF' skipover =>'' whole_match =>' this text here I want ' $ --- Check the documentation of the *latest version* for details on setting the $skip parameter, which controls skipping over text on the way to finding the tag; you might find its behavior counter-intuitive. -Tim *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 10/9: Adv OO-Perl/Parsing 10/16: Int. Perl 10/23 Perl Prog. | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From amcdowall at hotmail.com Thu Oct 5 13:17:00 2000 From: amcdowall at hotmail.com (ANDRE MCDOWALL) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: File Transfer Message-ID: Anyone know of a Perl or CGI script (or any script for that matter) that can transfer files from one server to another? And if possible, unzip a zipped file? The first part is more important (the transfer of files). Thanks! _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From admin at qdq.net Thu Oct 5 12:12:28 2000 From: admin at qdq.net (Ice Demon) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and References: <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> Message-ID: <39DCB67B.8F981DD0@qdq.net> You could try this $link = " this is the text I actually want"; $link =~ s///i; $link =~ s/<\/a>//i; print $link . "\n"; Todd Wells wrote: > I looked in the Cookbook, it has a recipe to extract the actual links (which > you'll see I'm doing in my code below), but I can't tell how to get the text > between the tags -- unless I'm looking at it incorrectly. > > this is the text I actually want > > -----Original Message----- > From: Rush Family [mailto:rush@citylinq.com] > Sent: Thursday, October 05, 2000 9:30 AM > To: Todd Wells; 'SPUG' > Subject: RE: SPUG: extracting text between and > > Although I do not have it in front of me to check, I believe this exact > problem is solved in the Perl Cookbook from O'Reilly. > > -----Original Message----- > From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of > Todd Wells > Sent: Thursday, October 05, 2000 8:55 AM > To: 'SPUG' > Subject: SPUG: extracting text between and > > I'm working on a little web automation routine and I've used HTML::LinkExtor > to extract the links from a web page, then I'm processing each of those > links. > > What I'd like to know is if there's some easy way that I could get the > original text that accompanied that link. e.g., "http://thislink"> this text here I want . > > sub link_scan > { > # input is $url, output is a list of links found at that URL > > my $url = shift; > my @linklist; my @ziplist; > > # retrieve HTML doc at URL > my $ua = new LWP::UserAgent; > my $request = new HTTP::Request('GET', $url); > my $response = $ua->request($request); > my $body = $response->content; > my $base = $response->base; > > # scan HTML doc for other URLS > my $link_parser = HTML::LinkExtor->new(); > $link_parser->parse($body); > my @parsed = $link_parser->links; > > foreach my $link (@parsed) > { > my $tag = $link->[0]; > > if (($tag eq "a") or ($tag eq "A")) > { > my $text = $link_parser->get_trimmed_text > my $new_url = new URI::URL $link->[2]; > my $full_url = $new_url->abs($url); > chomp $full_url; > unless (already_processed($full_url)) {push @linklist, > $full_url;} > } > } > return @linklist; > } > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From largest at largest.org Thu Oct 5 13:35:28 2000 From: largest at largest.org (Joel Grow) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and In-Reply-To: <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com> Message-ID: Great responses to this question. I should have thought of Text::Balanced, but I went right to regex like several other people have already mentioned. I also wanted to add that you can simplify some of this by using LWP::Simple, if you just want to grab the URL page text. Here's my version: #!/usr/local/bin/perl use strict; use LWP::Simple; use HTML::LinkExtor; use Data::Dumper; my $url = shift || 'http://www.largest.org'; # %links contains URLs as keys and the text as values # # ie: %links = ( 'http://www.halcyon.com/spug/' => 'SPUG homepage', # 'http://www.perl.com' => 'Perl homepage' ); my %links = link_scan($url); print Dumper (\%links); exit; sub link_scan { # input is $url, output is a list of links found at that URL my ($url) = @_; my %links; # retrieve HTML doc at URL my $page_text = get($url); my $link_parser = HTML::LinkExtor->new(); # scan HTML doc for other URLS $link_parser->parse($page_text); my @links = $link_parser->links; foreach my $link ( @links ) { # $link = ['a', # 'href', # 'http://www.foobar.com/baz/blotz.html' ] my ($tag, $attr, $url) = @$link; if ( $tag =~ /^[aA]$/ ) { # make sure to escape things like ? that can appear in URLs my $url_to_match = quotemeta $url; my ($tag_text) = ($page_text =~ /<\s* # start of the tag (<) $tag # the 'a' \s+ # some space $attr # the 'href' \s*=\s*"? # = and maybe a " $url_to_match # the URL \s*"?\s*>\s* # maybe a " and the > (.*?) # the text we want <\/a>/ixs); # the ending $links{$url} = $tag_text; } } return %links; } __END__ On Thu, 5 Oct 2000, Todd Wells wrote: > I'm working on a little web automation routine and I've used HTML::LinkExtor > to extract the links from a web page, then I'm processing each of those > links. > > What I'd like to know is if there's some easy way that I could get the > original text that accompanied that link. e.g., "http://thislink"> this text here I want . > > > sub link_scan > { > # input is $url, output is a list of links found at that URL > > my $url = shift; > my @linklist; my @ziplist; > > # retrieve HTML doc at URL > my $ua = new LWP::UserAgent; > my $request = new HTTP::Request('GET', $url); > my $response = $ua->request($request); > my $body = $response->content; > my $base = $response->base; > > # scan HTML doc for other URLS > my $link_parser = HTML::LinkExtor->new(); > $link_parser->parse($body); > my @parsed = $link_parser->links; > > foreach my $link (@parsed) > { > my $tag = $link->[0]; > > if (($tag eq "a") or ($tag eq "A")) > { > my $text = $link_parser->get_trimmed_text > my $new_url = new URI::URL $link->[2]; > my $full_url = $new_url->abs($url); > chomp $full_url; > unless (already_processed($full_url)) {push @linklist, > $full_url;} > } > } > return @linklist; > } > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From largest at largest.org Thu Oct 5 13:42:24 2000 From: largest at largest.org (Joel Grow) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: File Transfer In-Reply-To: Message-ID: On Thu, 5 Oct 2000, ANDRE MCDOWALL wrote: > Anyone know of a Perl or CGI script (or any script for that matter) > that can transfer files from one server to another? And if possible, > unzip a zipped file? The first part is more important (the transfer of > files). How about Net::FTP? This is from the perldoc: use Net::FTP; $ftp = Net::FTP->new("some.host.name"); $ftp->login("anonymous","me@here.there"); $ftp->cwd("/pub"); $ftp->get("that.file"); $ftp->quit; I don't know how comfortable you are with hardcoding passwords in a script. Joel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tuck at whistlingfish.net Thu Oct 5 13:46:01 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: File Transfer In-Reply-To: Message-ID: <14740000.970771561@flashingchance.whistlingfish.net> -- ANDRE MCDOWALL spake thusly: > Anyone know of a Perl or CGI script (or any script for that matter) > that can transfer files from one server to another? And if possible, > unzip a zipped file? The first part is more important (the transfer > of files). If you're looking to transfer files from one server to another, why not use one of the myriad tools already available (scp, rcp, rsync, ftp, etc.)? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001005/7633d310/attachment.bin From toddw at wrq.com Thu Oct 5 13:52:40 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and Message-ID: <1654BC972546D31189DA00508B318AC801C88267@charmander.wrq.com> Thanks to all who have responded... I guess I'm a little surprised that there isn't some existing simple method of HTML::Parser or ::LinkExtor to give you this info. You've all provided interesting ways of tackling the issue, I'll have to experiment to determine which one will work best for me. -----Original Message----- From: Todd Wells [mailto:toddw@wrq.com] Sent: Thursday, October 05, 2000 8:55 AM To: 'SPUG' Subject: SPUG: extracting text between and I'm working on a little web automation routine and I've used HTML::LinkExtor to extract the links from a web page, then I'm processing each of those links. What I'd like to know is if there's some easy way that I could get the original text that accompanied that link. e.g., this text here I want . sub link_scan { # input is $url, output is a list of links found at that URL my $url = shift; my @linklist; my @ziplist; # retrieve HTML doc at URL my $ua = new LWP::UserAgent; my $request = new HTTP::Request('GET', $url); my $response = $ua->request($request); my $body = $response->content; my $base = $response->base; # scan HTML doc for other URLS my $link_parser = HTML::LinkExtor->new(); $link_parser->parse($body); my @parsed = $link_parser->links; foreach my $link (@parsed) { my $tag = $link->[0]; if (($tag eq "a") or ($tag eq "A")) { my $text = $link_parser->get_trimmed_text my $new_url = new URI::URL $link->[2]; my $full_url = $new_url->abs($url); chomp $full_url; unless (already_processed($full_url)) {push @linklist, $full_url;} } } return @linklist; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From torin at daft.com Thu Oct 5 14:01:13 2000 From: torin at daft.com (Darren/Torin/Who Ever...) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: File Transfer In-Reply-To: "ANDRE MCDOWALL"'s message of "Thu, 05 Oct 2000 18:17:00 GMT" References: Message-ID: <87em1vxgcm.fsf@perv.daft.com> Andre McDowall, in an immanent manifestation of deity, wrote: >Anyone know of a Perl or CGI script (or any script for that matter) that >can transfer files from one server to another? And if possible, unzip a >zipped file? The first part is more important (the transfer of files). You could look at the code in CPAN.pm, distributed with Perl to see how it does it. Generally, it uses Net::FTP or LWP to transfer the file and then Compress::Zlib to uncompress it. From there, it then pulls out what it needs with Archive::Tar. I've also heard rumors of a module implementing the rsync protocol. CPAN says to contact Lee Eakin if you're interested in that... Darren -- Darren Stalder/2608 Second Ave, @282/Seattle, WA 98121-1212/USA/+1-206-ELF-LIPZ @ Make a little hot-tub in your soul. @ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From matthew.bustad at onebox.com Thu Oct 5 16:30:31 2000 From: matthew.bustad at onebox.com (Matthew Bustad) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: File Transfer Message-ID: <20001005213155.ZJPQ289.mta07.onebox.com@onebox.com> I have created daemons that spew preconfigured encrypted files and listens on a port. The perl client just connects and reads. The basics is in one of the begining books. -- Matthew Bustad matthew.bustad@seaslug.org ---- "ANDRE MCDOWALL" wrote: > Anyone know of a Perl or CGI script (or any script for that matter) > that can > transfer files from one server to another? And if possible, unzip a > zipped > file? The first part is more important (the transfer of files). > > Thanks! > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > Share information about yourself, create your own public profile at > > http://profiles.msn.com. > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > __________________________________________________ FREE voicemail, email, and fax...all in one place. Sign Up Now! http://www.onebox.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Thu Oct 5 17:57:21 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and In-Reply-To: <200010051758.KAA51415@denali.sdc.cs.boeing.com>; from Chuck Keagle on Thu, Oct 05, 2000 at 10:58:34AM -0700 References: <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> <200010051758.KAA51415@denali.sdc.cs.boeing.com> Message-ID: <20001005225721.A3450@timji.consultix.wa.com> On Thu, Oct 05, 2000 at 10:58:34AM -0700, Chuck Keagle wrote: > Now I'm new with Perl (just had Dr. Tim's beginner class a couple weeks Glad to see you're putting your education to use! 8-} > ago), but would a pattern match do the trick? > > m| ([\w ]*)| and $text = $1; > > If I'm way off base, please don't chastise me too harshly. Nice try, but you've fallen into the trap of underestimating the difficult of getting the regular expression right, and even if it were perfect in itself, you'd still have to worry about eliminating matches within comments, an entire problem unto itself. Best to use a debugged module written by a person whose Hubris will promote greater accuracy than a hand-rolled solution. Damian's Text::Balanced is what I'd suggest; I showed a sample run in a separate posting. -"Dr. Tim" *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 10/9: Adv OO-Perl/Parsing 10/16: Int. Perl 10/23 Perl Prog. | *========================================================================* > > -- > > (fixed width font) //\\ > __________________________ \\ > Chuck Keagle \\ .__=.\\ > chuck.keagle@boeing.com \____ ,' H-D \-\<) > Shared Services Group \ \______.,(_______/_:\ > (425) 865-5394 |==.\______// # /# #\ || : \____ > Fax: (425) 865-2221 '\\\ =''=//|_|##(O)##|| `./\---. > M/S 7J-04 _____________ /\ / ,`--'./# ======='//, //.\ . \ > _______ \ \_(_:_@O__)_///<_>O//// ( (@O ) ) > _____ \_____________/======'O' \ `-' / > __`-----'__________________`---'___ > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > -- *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 10/9: Adv OO-Perl/Parsing 10/16: Int. Perl 10/23 Perl Prog. | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dvergin at bigmindmedia.com Fri Oct 6 01:30:43 2000 From: dvergin at bigmindmedia.com (David Vergin) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Checking Email Addresses In-Reply-To: <20001005213155.ZJPQ289.mta07.onebox.com@onebox.com> Message-ID: <000301c02f5e$f4564660$0300000a@bigmindmedia.com> Working on an on-line conferencing package... User registers for the first time giving name and email address. Script reads data and sends a message with password to user's email address. But the user unknowingly mis-types his/her email address and then waits forever for the password to arrive. Is there a way to poll an email server to see if it recognizes a specific address? (And then display an error message to the user right away) Or if the script sent the email and checked for a bounce would the bounce arrive back in time to present an error message to the user waiting for a confirmation page after hitting 'Submit'? I.e. how fast do emails to bad addresses bounce? [hmmm... seems like there are several ways/levels in which an email address can be 'bad'] Is there a solution I am not considering? As always, url's, rtfm's, clues, suggestions of key words for searches, all welcome. tia David - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From daniel at chetlin.com Fri Oct 6 02:28:24 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: extracting text between and In-Reply-To: <39DCB67B.8F981DD0@qdq.net>; from admin@qdq.net on Thu, Oct 05, 2000 at 10:12:28AM -0700 References: <1654BC972546D31189DA00508B318AC801C88267@charmander.wrq.com> <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com> <1654BC972546D31189DA00508B318AC801C88257@charmander.wrq.com> <12920000.970769075@flashingchance.whistlingfish.net> <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> <200010051758.KAA51415@denali.sdc.cs.boeing.com> <1654BC972546D31189DA00508B318AC801C8825A@charmander.wrq.com> <39DCB67B.8F981DD0@qdq.net> Message-ID: <20001006002824.B5909@ilmd> Hi. This mail is in response to the various REx solutions posted for the HTML parsing question. Note please that my aim is not to criticize, merely to point out. I've left attributions off, as I'm responding to 5 different messages at once. > $link =~ s///i; > $link =~ s/<\/a>//i; This doesn't work for the following valid HTML 3.2 data: Bar Bar Baz Baz > m| ([\w ]*)| and $text = $1; For this one, problems include: Bar Bing Bar & Baz Baz > while ($html =~ /<[aA]\b[^>]*>([^<]*)/g) { Bar Baz Bar "<" Baz Baz > ($page_text =~ /<\s* # start of the tag (<) > $tag # the 'a' > \s+ # some space > $attr # the 'href' > \s*=\s*"? # = and maybe a " > $url_to_match # the URL > \s*"?\s*>\s* # maybe a " and the > > (.*?) # the text we want > <\/a>/ixs); # the ending (For these, assuming that the $url_to_match is set as "foo") Bar Baz Foo Bar Baz > Thanks to all who have responded... > > I guess I'm a little surprised that there isn't some existing simple > method of HTML::Parser or ::LinkExtor to give you this info. You've > all provided interesting ways of tackling the issue, I'll have to > experiment to determine which one will work best for me. There is. LinkExtor isn't the way to go, as its stated purpose is to grab _only_ the links. However, using TokeParser or Parser you shouldn't have many problems: use HTML::TokeParser; my $parser = HTML::TokeParser::->new($ARGV[0] || STDIN); my %urls; while ($_ = $parser->get_tag("a")) { push @{$urls{$_->[1]{href}}}, $parser->get_trimmed_text("/a") if exists $_->[1]{href}; } local $" = "\n\t"; print "$_ => @{$urls{$_}}\n" for keys %urls; Unless I'm misunderstanding what you want, this should do it. You end up with a hash, %urls, that contains each link in the document as keys, and as corresponding values a ref to an array of the text found between those links. -dlc P.S. Just as one final disclaimer, none of the code I've quoted above is bad Perl. I just worry about people seeing those solutions and thinking that they're robust enough to use in production. Please don't take my comments as anything but friendly comments. Thanks. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From daniel at chetlin.com Fri Oct 6 02:35:35 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Checking Email Addresses In-Reply-To: <000301c02f5e$f4564660$0300000a@bigmindmedia.com>; from dvergin@bigmindmedia.com on Thu, Oct 05, 2000 at 11:30:43PM -0700 References: <20001005213155.ZJPQ289.mta07.onebox.com@onebox.com> <000301c02f5e$f4564660$0300000a@bigmindmedia.com> Message-ID: <20001006003535.C5909@ilmd> On Thu, Oct 05, 2000 at 11:30:43PM -0700, David Vergin wrote: > Is there a way to poll an email server to see if it recognizes a specific > address? (And then display an error message to the user right away) > > Or if the script sent the email and checked for a bounce would the bounce arrive > back in time to present an error message to the user waiting for a confirmation > page after hitting 'Submit'? I.e. how fast do emails to bad addresses bounce? > [hmmm... seems like there are several ways/levels in which an email address can > be 'bad'] >From perlfaq9: =head2 How do I check a valid mail address? The basic answer to this question is: Do not. You can check the address itself to be sure that it's well-formed, but RFC 822 is so broad that you could throw some random characters together and they'd probably make a well-formed mail address. Even so, see Abigail's RFC::RFC822::Address for this. But don't try to come up with a way to make sure that the user has given an email address that will deliver to them. Simply have them repeat it to eliminate errors, or show it to them and ask for a confirmation. There's nothing else you can do. -dlc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From asherr at cs.unm.edu Fri Oct 6 11:05:20 2000 From: asherr at cs.unm.edu (Aryeh "Cody" Sherr) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Checking Email Addresses In-Reply-To: <000301c02f5e$f4564660$0300000a@bigmindmedia.com> Message-ID: There is a recipe for this in the O'Reilly Reg Exp book, and recipes 16.9 and 18.9 in the Perl cookbook make a stab at it using SMTP VRFY and EXPN. The short answer is that you can't with 100% accuracy. However, you can get fairly close by: - having them type it twice to prevent typos - checking the email for well-formedness, see http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/ckaddr.gz for a monster of a regexp written by Tom Christiansen that makes a stab at it, and asking the user to confirm if it looks like a bad address. - do an mx lookup for that domain to see if it's valid. here's some code blatantly taken from the cookbook: require Net::DNS; $domain_ok = 0; eval { Net::DNS->import('mx'); $domain_ok =1; }; - then try to mail them something, if it fails, they'll have to try again. that should get about 99.9% of human users. Cody On Thu, 5 Oct 2000, David Vergin wrote: > Working on an on-line conferencing package... > > User registers for the first time giving name and email address. > Script reads data and sends a message with password to user's email address. > > But the user unknowingly mis-types his/her email address and then waits forever > for the password to arrive. > > > Is there a way to poll an email server to see if it recognizes a specific > address? (And then display an error message to the user right away) > > Or if the script sent the email and checked for a bounce would the bounce arrive > back in time to present an error message to the user waiting for a confirmation > page after hitting 'Submit'? I.e. how fast do emails to bad addresses bounce? > [hmmm... seems like there are several ways/levels in which an email address can > be 'bad'] > > Is there a solution I am not considering? > > As always, url's, rtfm's, clues, suggestions of key words for searches, all > welcome. > > tia > David > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From admin at qdq.net Fri Oct 6 12:11:16 2000 From: admin at qdq.net (Ice Demon) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Checking Email Addresses References: <000301c02f5e$f4564660$0300000a@bigmindmedia.com> Message-ID: <39DE07B4.244E01D4@qdq.net> David Vergin wrote: > Working on an on-line conferencing package... > > User registers for the first time giving name and email address. > Script reads data and sends a message with password to user's email address. > > But the user unknowingly mis-types his/her email address and then waits forever > for the password to arrive. > > > Is there a way to poll an email server to see if it recognizes a specific > address? (And then display an error message to the user right away) > > Or if the script sent the email and checked for a bounce would the bounce arrive > back in time to present an error message to the user waiting for a confirmation > page after hitting 'Submit'? I.e. how fast do emails to bad addresses bounce? > [hmmm... seems like there are several ways/levels in which an email address can > be 'bad'] > > Is there a solution I am not considering? > > As always, url's, rtfm's, clues, suggestions of key words for searches, all > welcome. > > tia > David There is a module called Mail::CheckUser at http://search.cpan.org/search?dist=Mail-CheckUser It will do 3 things (which you can turn off some) 1. Checks the syntax of the email address. 2. Checks the MX record for the email's domain name 3. It tries to connect to the email server via SMTP to see if the mailbox is valid. The problem with using this module is that is takes a while to check these things and the browser can time out during the check or the person can be waiting for a while for this stuff to be checked. Your best bet would be to do what Daniel said and have them enter their email twice rather than checking to see if it can actually reach them. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From aaron at activox.com Fri Oct 6 14:22:52 2000 From: aaron at activox.com (Aaron Salo) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Checking Email Addresses In-Reply-To: <39DE07B4.244E01D4@qdq.net> References: <000301c02f5e$f4564660$0300000a@bigmindmedia.com> Message-ID: <3.0.5.32.20001006122252.00ee6100@pi.pair.com> At 10:11 AM 10/6/00 -0700, Ice Demon wrote: >while for this stuff to be checked. Your best bet would be to do what Daniel said >and have them enter their email twice rather than checking to see if it can >actually reach them. That's a good idea - another thing that works in conjunction with that is to set up a specific mail alias on your server like 'notifications@foo.com' specifically for the purpose of handling these sort of things, and always send the outbound password-mail FROM: that user with proper RFC822 Reply-To and Return-Path headers. Then set an entry in your sendmail alias.users file that will catch all inbound mail to that specific address and pipe them to a script that will [notify someone of the bounce|update the db that the address bounces|play a little tune]. Then in that script you can grep the mail body for the bounce reason and even do some intelligent rule-based forwarding depending on what the bounce reason was more flexibly than procmail. Also, some people reflexively reply to such messages, and if you don't grep a mail failure header or other telltale string out of the response, you can figure it was one of those folks and you can auto-reply to them and tell them to put down the crack pipe and re-read the instructions. Or you can do the internic 'mail-from' thing where you force them to reply to your password message before you light up their password, let the script take care of all that stuff. Ain't life grand?? Or if you're a procmail fan just make a user called 'notifications' and go that way with it. Cheers ----------------- 'a good website is no defense against a bad business plan' ----------------- Aaron Salo aaron@activox.com ------------------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at xenon.cobaltgroup.com Sat Oct 7 20:29:16 2000 From: ajalis at xenon.cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Eastside Perl Update Message-ID: <20001007182916.A24791@xenon.cobaltgroup.com> Tim Maher has informed me I have just been enthroned the new ESPUG "Emperor". [Trumpets blare.] :-) Before the merriment and festivities begin I would like to make a few announcements. The most important thing for right now is to re-start our monthly Eastside meetings, which we all miss sorely. We'll continue to meet every 4th Wednesday of the month at Lucent's Redmond offices, near the Redmond Town Center. I'll send out detailed directions with the official announcement the week of the meeting. We are still looking for speakers. So you are interested let me know. Here are some reasons you want to do this. If you are looking for a Perl job or are a freelance Perl contractor speaking at these meetings is an excellent way to show everyone how clever you are and how much they want to hire you. If your company needs Perl people you can put subliminal recruiting messages in your slides and thereby implant them into the brightest Perl minds in the area. If you already have the perfect job but have noticed recently that your close friends don't get your clever Perl jokes and subtle regexp humor, this is an excellent time to replace them with brand new Perl friends. Again the best way to do this is to give a talk at our meeting. So this is a great opportunity to improve your life in a lot of different ways. You can talk about some cool Perl module or application that you have recently stumbled upon. Or you can present some sections from a Perl book. Or you could talk about how you have used Perl to create cool stuff. Another interesting presentation could be how to write a module for CPAN, and the mechanics of preparing it for submission, submitting it, and updating it. I am just thinking out aloud here. You can talk about anything that you want and that you think other Perl folks might be interested in. Hurry before all the speaking slots are taken in the mad stampede this message is sure to generate :-) Feel free to send me e-mail to discuss presentation ideas. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From daniel at chetlin.com Sun Oct 8 21:29:59 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: "Clobberation" in ($c,$d)=($d,$c) Message-ID: <20001008192959.A2025@ilmd> During the Q&A session at the Perligata meeting, someone mentioned that if you alias a variable and then use it on one side of a variable switch, you get "clobberation". I was thinking about that tonight and decided to take a look, but I couldn't reproduce it. If memory serves, the problem was with constructs like: *e = \$c; ($c, $d) = ($d, $e); But that seems to work fine, so I must be remembering wrong. Can someone refresh my memory? Thanks! -dlc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dvergin at bigmindmedia.com Mon Oct 9 14:03:15 2000 From: dvergin at bigmindmedia.com (David Vergin) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Trapping Named Anchor References In-Reply-To: Message-ID: <000501c03223$942b8c60$0300000a@bigmindmedia.com> I need to capture a named anchor reference for a redirect. Story line: A user clicks on a saved link or a link in an email like: http://www.myserver.com/cgi/coolsite.pl?page=124#item16 but the coolsite.pl script notices the user doesn't have a logged-in cookie so it displays a log-in page rather than the requested content page. Fine so far. The user fills in UserID and Password and clicks on Submit. The form action specifies the log-in script which verifies the users info and then does a re-direct to the url the user originally wanted to see (which still appears in its entirety in the browser Location box) to be displayed by the normal display script. Everything works fine except the named anchor reference. Here's the problem: I can find no way to trap the '#item16' portion of the url. I need that in order to compose the complete URL for the 'Location:' header so the user does not end up confused to find themselves at the top of a long page when they really want to see an item farther down. On Linux/Apache, the anchor ref does not appear anywhere in %ENV You can check this at: http://caucus.bigmindmedia.com/cgi-dv/showenv.pl?data=123#AnchorRef Not surprisingly then, I can find no tool in CGI.pm to grab it. My searches of the likely archives have come up dry. Lest you suggest integrating the User Verification into the main script, I should mention that one purpose of the redirect is to avoid the 'Resubmit Form Data' problem. My best solution is redundancy: Always dup the anchor ref in the query string. Thus: http://www.myserver.com/cgi/coolsite.pl?page=124&anch=item16#item16 This allows me to handle any link the user may have saved and to rebuild the anchor ref from the query string during log-in. It's not exactly normalized but it does the job. Any suggestions? As always, rtfm's, url's, suggested lines of inquiry, wise counsel, key words for searches: all welcome. tia david ------------------------------------------------------------- $q=q { $JaPh=~/n[aieuo]c/;$trk="sheelleerr";tr/$@%&*/ /;}; ++$i,map{++$i;print,for($q=~/.{$i}(\w| ).{0,$_}/g)}(9,2,4,0); ------------------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Mon Oct 9 14:07:33 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: "Clobberation" in ($c,$d)=($d,$c) References: <20001008192959.A2025@ilmd> Message-ID: <39E21775.97B78576@activestate.com> Daniel Chetlin wrote: > > During the Q&A session at the Perligata meeting, someone mentioned that > if you alias a variable and then use it on one side of a variable > switch, you get "clobberation". I was thinking about that tonight and > decided to take a look, but I couldn't reproduce it. > > If memory serves, the problem was with constructs like: > > *e = \$c; > ($c, $d) = ($d, $e); > > But that seems to work fine, so I must be remembering wrong. Can someone > refresh my memory? What Damian wrote on the board was not exactly what was needed to produce the problem, just the basic idea. Try this: (*c1, *d1) = (\$c, \$d); ($c, $d) = (10, 20); ($c, $d) = ($d1, $c1); print "$c, $d\n"; The result should be perfectly clear :) Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ced at carios2.ca.boeing.com Mon Oct 9 14:23:11 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Trapping Named Anchor References Message-ID: <200010091923.MAA03137@carios2.ca.boeing.com> > > > I need to capture a named anchor reference for a redirect. > > Story line: > A user clicks on a saved link or a link in an email like: > > http://www.myserver.com/cgi/coolsite.pl?page=124#item16 > > but the coolsite.pl script notices the user doesn't have a logged-in cookie so > it displays a log-in page rather than the requested content page. Fine so far. > > The user fills in UserID and Password and clicks on Submit. The form action > specifies the log-in script which verifies the users info and then does a > re-direct to the url the user originally wanted to see (which still appears in > its entirety in the browser Location box) to be displayed by the normal display > script. > > Everything works fine except the named anchor reference. > > Here's the problem: I can find no way to trap the '#item16' portion of the url. > I need that in order to compose the complete URL for the 'Location:' header so > the user does not end up confused to find themselves at the top of a long page > when they really want to see an item farther down. > > On Linux/Apache, the anchor ref does not appear anywhere in %ENV > > You can check this at: > http://caucus.bigmindmedia.com/cgi-dv/showenv.pl?data=123#AnchorRef > > Not surprisingly then, I can find no tool in CGI.pm to grab it. > > My searches of the likely archives have come up dry. > > Lest you suggest integrating the User Verification into the main script, I > should mention that one purpose of the redirect is to avoid the 'Resubmit Form > Data' problem. > > My best solution is redundancy: Always dup the anchor ref in the query string. > Thus: > > http://www.myserver.com/cgi/coolsite.pl?page=124&anch=item16#item16 > > This allows me to handle any link the user may have saved and to rebuild the > anchor ref from the query string during log-in. It's not exactly normalized but > it does the job. > > Any suggestions? > Perhaps URI would help... ? use URI; my $uri = "http://caucus.bigmindmedia.com/cgi-dv/showenv.pl?data=123#AnchorRef"; my $u = URI->new($uri); print $u->fragment; # AnchorRef __END__ -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tuck at whistlingfish.net Mon Oct 9 15:03:10 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:40 2004 Subject: SPUG: Trapping Named Anchor References In-Reply-To: <000501c03223$942b8c60$0300000a@bigmindmedia.com> Message-ID: <3970000.971121790@benzene> -- David Vergin spake thusly: > My best solution is redundancy: Always dup the anchor ref in the > query string. Thus: > > http://www.myserver.com/cgi/coolsite.pl?page=124&anch=item16#item16 > > This allows me to handle any link the user may have saved and to > rebuild the anchor ref from the query string during log-in. It's not > exactly normalized but it does the job. > > Any suggestions? > > As always, rtfm's, url's, suggested lines of inquiry, wise counsel, > key words for searches: all welcome. As far as I can tell, this is the only way to do it. The problem is that the browser isn't passing this information to the server; it's simply using it to jump the display to a particular anchor on the page. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001009/c8901f73/attachment.bin From brian at tangent.org Mon Oct 9 15:03:11 2000 From: brian at tangent.org (Brian Aker) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Trapping Named Anchor References References: <200010091923.MAA03137@carios2.ca.boeing.com> Message-ID: <39E2247F.662FB7B1@tangent.org> ced@carios2.ca.boeing.com wrote: > > > > > > I need to capture a named anchor reference for a redirect. > > > > Story line: > > A user clicks on a saved link or a link in an email like: > > > > http://www.myserver.com/cgi/coolsite.pl?page=124#item16 > > > > but the coolsite.pl script notices the user doesn't have a logged-in cookie so > > it displays a log-in page rather than the requested content page. Fine so far. > > > > The user fills in UserID and Password and clicks on Submit. The form action > > specifies the log-in script which verifies the users info and then does a > > re-direct to the url the user originally wanted to see (which still appears in > > its entirety in the browser Location box) to be displayed by the normal display > > script. > > > > Everything works fine except the named anchor reference. > > > > Here's the problem: I can find no way to trap the '#item16' portion of the url. > > I need that in order to compose the complete URL for the 'Location:' header so > > the user does not end up confused to find themselves at the top of a long page > > when they really want to see an item farther down. > > > > On Linux/Apache, the anchor ref does not appear anywhere in %ENV > > > > You can check this at: > > http://caucus.bigmindmedia.com/cgi-dv/showenv.pl?data=123#AnchorRef Assuming mod_perl (and I understand what you are asking for) my $r = Apache->request; my $string = $r->the_request(); That will give you all the info that you need. You may also want to look into what parsed_uri() returns when called from $r. -Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Wed Oct 11 10:26:41 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? Message-ID: <1654BC972546D31189DA00508B318AC801C882B1@charmander.wrq.com> I'm creating a module which uses some other objects internally, so I have multiple package statements in the same .pm file to define these other objects. Is there a good reason why I shouldn't do this? I'd prefer to keep it all in one file. However, I'm having a problem which I think is related. I have my module all in one file that contains 3 package statements, for objects A, B and C. e.g.: package A; sub new { blah } sub log { fooblah } 1; package B; @ISA = sq ( A ); sub new { blahblah } 1; package C; sub new { moblah } 1; However, when I call $pack_b = B->new(); $pack_b->log("foobar"), I get: Can't locate package "A" for @B::ISA at A.pm line 274. Can't locate package "A" for @B::ISA at A.pm line 274. Can't locate object method "log" via package "B" at A.pm line 274. Can't locate package "A" for @B::ISA. At the moment, my package "A" is just A.pm sitting in the same directory as the program which calls it. Is there a way to make this work or am I forced to put objects A, B and C in separate files? -Todd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Wed Oct 11 12:16:52 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? References: <1654BC972546D31189DA00508B318AC801C882B1@charmander.wrq.com> Message-ID: <39E4A084.ACAC2FA1@activestate.com> Todd Wells wrote: > > I'm creating a module which uses some other objects internally, so I have > multiple package statements in the same .pm file to define these other > objects. Is there a good reason why I shouldn't do this? I'd prefer to > keep it all in one file. However, I'm having a problem which I think is > related. > > I have my module all in one file that contains 3 package statements, for > objects A, B and C. e.g.: > > package A; > sub new { blah } > sub log { fooblah } > 1; > > package B; > @ISA = sq ( A ); > sub new { blahblah } > 1; > > package C; > sub new { moblah } > 1; > > However, when I call > > $pack_b = B->new(); > $pack_b->log("foobar"), I get: > > Can't locate package "A" for @B::ISA at A.pm line 274. > Can't locate package "A" for @B::ISA at A.pm line 274. > Can't locate object method "log" via package "B" at A.pm line 274. > Can't locate package "A" for @B::ISA. Try this: package A; sub foo { print "It worked\n" } package B; @ISA = qw ( A ); sub new { bless [], shift } $b = B->new; $b->foo; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Wed Oct 11 13:08:56 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? Message-ID: <1654BC972546D31189DA00508B318AC801C882B2@charmander.wrq.com> When I run your code it works, but this code is in the same file. If I save packages A and B in A.pm (and append 1;), and then create test1.pl that has this: # test1.pl use A; $b = B->new; $b->foo; Now when I run test1.pl, I get this: ~/myperl$ perl test1.pl Can't locate A.pm in @INC (@INC contains: d:/Perl/lib d:/Perl/site/lib .) at tes t1.pl line 1. BEGIN failed--compilation aborted at test1.pl line 1. ~/myperl$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Wed Oct 11 13:21:45 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? References: <1654BC972546D31189DA00508B318AC801C882B1@charmander.wrq.com> Message-ID: <39E4AFB9.6FDBFF8D@activestate.com> Todd Wells wrote: > > I'm creating a module which uses some other objects internally, so I have > multiple package statements in the same .pm file to define these other > objects. Is there a good reason why I shouldn't do this? I'd prefer to > keep it all in one file. However, I'm having a problem which I think is > related. There seems to be a lot of fuzziness among the common Perl community, as to what *order* Perl executes all of the source code that you give it. Perlers talk about 'compile time' and 'run time', but in reality the two are very much mixed together. For example you can use BEGIN blocks to 'run' code during 'compile' time, and eval blocks to 'compile' Perl during 'run' time. There are a few things I have found along my journey, that help clear the waters a bit. 1) use Foo qw(Bar Baz); is equivalent to: BEGIN { require Foo; Foo->import(qw(Bar Baz)); } so you could infer, that 'BEGIN' is the only real compile time directive. 2) require Foo; is similar to: eval `cat Foo.pm`; eval, as you know, compiles and runs a piece of Perl code. 3) In corollary, the statement: use Foo qw(Bar Baz); will: A) immediately read in Foo.pm. B) compile the code, executing each BEGIN (and use) as it goes. C) run the (file scoped, or global, or non-subroutine) code of Foo.pm D) call Foo->import(qw(Bar Baz)); E) continue compiling the next line after 'use Foo ...' A couple weeks ago I wrote some sample code to verify this process. The code is in 4 files, shown below: -------------------8<---------------------- # foo.pl use X; sub END {print "foo END\n"} print "foo global\n"; sub INIT {print "foo INIT\n";} sub CHECK {print "foo CHECK\n";} sub BEGIN {print "foo BEGIN\n";} use Z; -------------------8<---------------------- # X.pm package X; sub END {print "X END\n"} sub unimport {print "X unimport\n"} print "X global\n"; sub import {print "X import\n"} sub INIT {print "X INIT\n"} sub CHECK {print "X CHECK\n"} sub BEGIN {print "X BEGIN\n"} use Y; 1; -------------------8<---------------------- # Y.pm package Y; sub END {print "Y END\n"} print "Y global\n"; sub import {print "Y import\n"} sub INIT {print "Y INIT\n"} sub CHECK {print "Y CHECK\n"} sub BEGIN {print "Y BEGIN\n"} 1; -------------------8<---------------------- # Z.pm package z; sub END {print "z END\n"} print "z global\n"; sub import {print "z import\n"} sub INIT {print "z INIT\n"} sub CHECK {print "z CHECK\n"} sub BEGIN {print "z BEGIN\n"} 1; -------------------8<---------------------- If you run 'perl foo.pl' you get: X BEGIN Y BEGIN Y global Y import X global X import foo BEGIN z BEGIN z global z CHECK foo CHECK Y CHECK X CHECK X INIT Y INIT foo INIT z INIT foo global z END foo END Y END X END Note: You'll need 5.6 for CHECK to work. Try perl -c foo.pl to see where Perl thinks compile time ends. Notice the difference in execution order between INIT and CHECK. As I took the time to understand this, my confidence in knowing what Perl was doing with my code really solidified. Hope this helps. Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ced at carios2.ca.boeing.com Wed Oct 11 13:26:38 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? Message-ID: <200010111826.LAA29759@carios2.ca.boeing.com> > If I save packages A and B in A.pm (and append 1;), and then create test1.pl >that has this: ># test1.pl >use A; >$b = B->new; >$b->foo; >Now when I run test1.pl, I get this: >~/myperl$ perl test1.pl >Can't locate A.pm in @INC (@INC contains: d:/Perl/lib d:/Perl/site/lib .) at >tes >t1.pl line 1. >BEGIN failed--compilation aborted at test1.pl line 1. > ~/myperl$ use lib "/path/to/module"; # e.g. use lib "C:/myhome/lib"; use A; ... hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Wed Oct 11 13:36:01 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? References: <1654BC972546D31189DA00508B318AC801C882B2@charmander.wrq.com> Message-ID: <39E4B311.1F843F90@activestate.com> Todd Wells wrote: > > When I run your code it works, but this code is in the same file. > > If I save packages A and B in A.pm (and append 1;), and then create test1.pl > that has this: > > # test1.pl > use A; > $b = B->new; > $b->foo; > > Now when I run test1.pl, I get this: > > ~/myperl$ perl test1.pl > Can't locate A.pm in @INC (@INC contains: d:/Perl/lib d:/Perl/site/lib .) at > tes > t1.pl line 1. > BEGIN failed--compilation aborted at test1.pl line 1. > ~/myperl$ Where did you put A.pm. It should be in the same dir as test1.pl, and you need to run it from there as well. 'perl test1.pl' works for me with these 2 files: --------------8<---------------- # A.pm package A; sub foo { print "It worked\n" } package B; @ISA = qw ( A ); sub new { bless [], shift } 1; --------------8<---------------- # test1.pl use A; $b = B->new; $b->foo; --------------8<---------------- Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Wed Oct 11 13:43:10 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? Message-ID: <1654BC972546D31189DA00508B318AC801C882B6@charmander.wrq.com> Well, yes, it would help if I actually SAVED A.pm, wouldn't it?? :-) Unfortunately, while the example works, I'm still having the problem in my specific case. I'll try to distill my problem into a better example. -Todd -----Original Message----- From: ced@carios2.ca.boeing.com [mailto:ced@carios2.ca.boeing.com] Sent: Wednesday, October 11, 2000 11:27 AM To: briani@activestate.com; toddw@wrq.com Cc: spug-list@pm.org Subject: RE: SPUG: Modules - more than one object in file? > If I save packages A and B in A.pm (and append 1;), and then create test1.pl >that has this: ># test1.pl >use A; >$b = B->new; >$b->foo; >Now when I run test1.pl, I get this: >~/myperl$ perl test1.pl >Can't locate A.pm in @INC (@INC contains: d:/Perl/lib d:/Perl/site/lib .) at >tes >t1.pl line 1. >BEGIN failed--compilation aborted at test1.pl line 1. > ~/myperl$ use lib "/path/to/module"; # e.g. use lib "C:/myhome/lib"; use A; ... hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From toddw at wrq.com Wed Oct 11 14:21:26 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? Message-ID: <1654BC972546D31189DA00508B318AC801C882B9@charmander.wrq.com> Okay, I still don't know why I'm having these problems, but here's the specific problem I'm having, and I just don't understand why or what I need to do to fix it. The TestCase package is in the same file as TestEngine (TestEngine.pm). TestCase @ISA TestEngine, or so I've said in the TestCase package. A method of TestCase is trying to call the logger() method of TestEngine. On the line where logger() is called, it generates this error stack: Can't locate package "TestEngine" for @TestCase::ISA at TestEngine.pm line 254, line 54. Can't locate package "TestEngine" for @TestCase::ISA at TestEngine.pm line 254, line 54. Can't locate object method "logger" via package "TestCase" at TestEngine.pm line 254, line 54. Can't locate package "TestEngine" for @TestCase::ISA, line 54. Line 254 calls logger() and line 54 is where the logger() method actually begins. I'm completely stumped why I'm getting 'can't locate package "TestEngine"' after I successfully 'use TestEngine;' in my very first line of code. Any help you can give is appreciated, this has already taken up way too much of my time. -Todd P.S. For anyone interested enough to care, I've attached the two files I'm working with (the module and the code which exercises it). The error occurs in the test() method of TestCase. -----Original Message----- From: Todd Wells [mailto:toddw@wrq.com] Sent: Wednesday, October 11, 2000 11:43 AM To: 'ced@carios2.ca.boeing.com'; briani@activestate.com; 'SPUG' Subject: RE: SPUG: Modules - more than one object in file? Well, yes, it would help if I actually SAVED A.pm, wouldn't it?? :-) Unfortunately, while the example works, I'm still having the problem in my specific case. I'll try to distill my problem into a better example. -Todd -----Original Message----- From: ced@carios2.ca.boeing.com [mailto:ced@carios2.ca.boeing.com] Sent: Wednesday, October 11, 2000 11:27 AM To: briani@activestate.com; toddw@wrq.com Cc: spug-list@pm.org Subject: RE: SPUG: Modules - more than one object in file? > If I save packages A and B in A.pm (and append 1;), and then create test1.pl >that has this: ># test1.pl >use A; >$b = B->new; >$b->foo; >Now when I run test1.pl, I get this: >~/myperl$ perl test1.pl >Can't locate A.pm in @INC (@INC contains: d:/Perl/lib d:/Perl/site/lib .) at >tes >t1.pl line 1. >BEGIN failed--compilation aborted at test1.pl line 1. > ~/myperl$ use lib "/path/to/module"; # e.g. use lib "C:/myhome/lib"; use A; ... hope this helps, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ -------------- next part -------------- A non-text attachment was scrubbed... Name: TestEngine.pm Type: application/octet-stream Size: 5205 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001011/25d7bc59/TestEngine.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: testtest.pl Type: application/octet-stream Size: 499 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001011/25d7bc59/testtest.obj From toddw at wrq.com Wed Oct 11 14:44:20 2000 From: toddw at wrq.com (Todd Wells) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? Message-ID: <1654BC972546D31189DA00508B318AC801C882BB@charmander.wrq.com> Aha!! This is what got me... Thanks so much! -----Original Message----- From: Prabhjot Basi [mailto:pbasi@n2h2.com] Sent: Wednesday, October 11, 2000 12:42 PM To: Todd Wells Subject: RE: SPUG: Modules - more than one object in file? Tried running your example - But came across syntax error @ISA = qw( "TestEngine"); ^ ^ it should be @ISA = qw( TestEngine ); Hope it helps Prabhjot On Wed, 11 Oct 2000, Todd Wells wrote: :)Okay, I still don't know why I'm having these problems, but here's the :)specific problem I'm having, and I just don't understand why or what I need :)to do to fix it. :) :)The TestCase package is in the same file as TestEngine (TestEngine.pm). :)TestCase @ISA TestEngine, or so I've said in the TestCase package. A method :)of TestCase is trying to call the logger() method of TestEngine. On the :)line where logger() is called, it generates this error stack: :) :)Can't locate package "TestEngine" for @TestCase::ISA at TestEngine.pm line :)254, :) line 54. -- Prabhjot K. Basi N2H2 Inc. Advanced Technologies http://www.n2h2.com Voice (206)336-1510 Fax (206)336-1541 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From torin at daft.com Wed Oct 11 16:01:47 2000 From: torin at daft.com (Darren/Torin/Who Ever...) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? In-Reply-To: Brian Ingerson's message of "Wed, 11 Oct 2000 11:21:45 -0700" References: <1654BC972546D31189DA00508B318AC801C882B1@charmander.wrq.com> <39E4AFB9.6FDBFF8D@activestate.com> Message-ID: <87d7h7rt1g.fsf@perv.daft.com> I came in a bit late to say much but I did want to make a few comments. (Well, more than a few comments; my instructor side came out to play.) Brian Ingerson, in an immanent manifestation of deity, wrote: >There seems to be a lot of fuzziness among the common Perl community, as >to what *order* Perl executes all of the source code that you give it. It's really not fuzzy at all. It is in a definitive order. But I'll grant that some folks ideas about the order is fuzzy. :) >Perlers talk about 'compile time' and 'run time', but in reality the two >are very much mixed together. For example you can use BEGIN blocks to >'run' code during 'compile' time, and eval blocks to 'compile' Perl >during 'run' time. I disagree about them being mixed together. All code gets turned into a parse tree during compile time. Then, to run the code, Perl walks the parse tree executing the ops that it finds along the way. Perl does want to be quite the enabler though. :) It gives you hooks so you can run code during compile time - why should the executable have all the fun? That's the BEGIN statement. Perl also doesn't want to be discriminatory. It likes to enable you on both sides of the compile/run phase. So, if in the middle of your running code, you'd like to call the compiler again, you can do that with eval. No fuzziness whatsoever. Perl just wants to give the programmer as much control as possible. At any point along the way, you can modify what is going on. Larry knows that -you- know -your- situation way better than he ever will, so he gives you hooks to do whatever you want whenever you want. Try to convince the other language designers to give you that kind of control. (Heh. Can you tell I like Perl?) In summary (and in order): BEGIN - run this code *NOW* as soon as the block is closed forgoing all else. CHECK - run this code as late as possible in the compile stage. INIT - run this code as soon as possible in the run stage END - run this code as late as possible (in the run stage of course). If you define these multiple times, Perl will accumulate them for you. Both BEGIN and INIT will run in FIFO order - first in, first out. To me, this is the obvious order. CHECK and END will run in LIFO order - last in, first out. If you read the descriptions, this will make sense even if it is somewhat surprising. Each one will run as late as possible but previously defined CHECK/END blocks might have taken the very last place before this one got to it. Neither CHECK nor INIT are defined in 5.004. CHECK isn't defined in 5.005. Note that before 5.6, all these blocks would be run even if you specified the -c switch. With 5.6, -c will only run the BEGIN and CHECK blocks. I wrote the following to make sure I wasn't lying: {2}[0]~ perv:-) perl-5.6 -we 'BEGIN {warn "begin 1\n";} BEGIN {warn "begin 2\n";} sub CHECK {warn "check 1\n";} sub CHECK {warn "check 2\n";} sub INIT {warn "init 1\n";} sub INIT {warn "init 2\n";} END {warn "end 1\n";} sub END {warn "end 2\n";}' begin 1 begin 2 check 2 check 1 init 1 init 2 end 2 end 1 {2}[0]~ perv:-) perl-5.005 -we 'BEGIN {warn "begin 1\n";} BEGIN {warn "begin 2\n";} sub CHECK {warn "check 1\n";} sub CHECK {warn "check 2\n";} sub INIT {warn "init 1\n";} sub INIT {warn "init 2\n";} END {warn "end 1\n";} sub END {warn "end 2\n";}' begin 1 begin 2 Subroutine CHECK redefined at -e line 2. init 1 init 2 end 2 end 1 {2}[0]~ perv:-) perl-5.004 -we 'BEGIN {warn "begin 1\n";} BEGIN {warn "begin 2\n";} sub CHECK {warn "check 1\n";} sub CHECK {warn "check 2\n";} sub INIT {warn "init 1\n";} sub INIT {warn "init 2\n";} END {warn "end 1\n";} sub END {warn "end 2\n";}' begin 1 begin 2 Subroutine CHECK redefined at -e line 2. Subroutine INIT redefined at -e line 3. end 2 end 1 > so you could infer, that 'BEGIN' is the only real compile time >directive. Well, CHECK is a compile-time directive as well but that's recent. >2) require Foo; > is similar to: > eval `cat Foo.pm`; It's actually significantly more complicated than that. The three things that leap to mind are: 1) It tracks if it's been loaded already and won't run it again if so. 2) It searches the @INC path for the file - under taint this won't include the current directory. 3) dies if Foo.pm doesn't return true at the end. This is why you usually see 1; at the end of Perl modules. Charles DeRykus, in an immanent manifestation of deity, wrote: >use lib "/path/to/module"; # e.g. use lib "C:/myhome/lib"; >use A; >... BTW, I've found that the FindBin module helps lots. From the manpage: use FindBin; use lib "$FindBin::Bin/../lib"; This way you don't have to encode pathnames into your module. If you also used File::Path, your script would be highly transportable. Darren -- Darren Stalder/2608 Second Ave, @282/Seattle, WA 98121-1212/USA/+1-206-ELF-LIPZ @ Make a little hot-tub in your soul. @ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From sb at sdm.de Wed Oct 11 17:14:09 2000 From: sb at sdm.de (Steffen Beyer) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? In-Reply-To: <1654BC972546D31189DA00508B318AC801C882B1@charmander.wrq.com> from Todd Wells at "Oct 11, 2000 08:26:41 am" Message-ID: <200010112214.AAA08946@muccpu1.muc.sdm.de> Hello Todd Wells, in a previous mail you wrote: > I'm creating a module which uses some other objects internally, so I have > multiple package statements in the same .pm file to define these other > objects. Is there a good reason why I shouldn't do this? I'd prefer to > keep it all in one file. However, I'm having a problem which I think is > related. > > I have my module all in one file that contains 3 package statements, for > objects A, B and C. e.g.: > > package A; > sub new { blah } > sub log { fooblah } > 1; > > package B; > @ISA = sq ( A ); > sub new { blahblah } > 1; > > package C; > sub new { moblah } > 1; > > However, when I call > > $pack_b = B->new(); > $pack_b->log("foobar"), I get: > > Can't locate package "A" for @B::ISA at A.pm line 274. > Can't locate package "A" for @B::ISA at A.pm line 274. > Can't locate object method "log" via package "B" at A.pm line 274. > Can't locate package "A" for @B::ISA. > > At the moment, my package "A" is just A.pm sitting in the same directory as > the program which calls it. > > Is there a way to make this work or am I forced to put objects A, B and C in > separate files? Since nobody was able to give you a difinitive answer so far, I'll try to give my $0.02 as well - for what it's worth... :-) Apparently you have to prevent perl from searching the "B" and "C" modules in the file system, where they cannot be located because they're no separate files and since they're already in memory. Therefore you might have to inform perl that the modules are already in memory. perl keeps track of this information in the reserved hash %INC - not to be confused with @INC, the include path! Try this (at the bottom of "A.pm", before the final "1;"): $INC{'B.pm'} = $INC{'A.pm'}; $INC{'C.pm'} = $INC{'A.pm'}; That should work if my extrapolation of how Perl works internally is correct! :-) (Please let me know if it does! Thank you!) P.S.: I don't think you'll need all those "1;" except for the last one! Good luck! Cheers, -- Steffen Beyer http://www.engelschall.com/u/sb/whoami/ (Who am I) http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...) http://www.engelschall.com/u/sb/download/ (Free Perl and C Software) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Thu Oct 12 12:04:22 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? References: <1654BC972546D31189DA00508B318AC801C882B1@charmander.wrq.com> <39E4AFB9.6FDBFF8D@activestate.com> <87d7h7rt1g.fsf@perv.daft.com> Message-ID: <39E5EF16.9772A374@activestate.com> "Darren/Torin/Who Ever..." wrote: > > I came in a bit late to say much but I did want to make a few comments. > (Well, more than a few comments; my instructor side came out to play.) > > Brian Ingerson, in an immanent manifestation of deity, wrote: > >There seems to be a lot of fuzziness among the common Perl community, as > >to what *order* Perl executes all of the source code that you give it. > > It's really not fuzzy at all. It is in a definitive order. But I'll > grant that some folks ideas about the order is fuzzy. :) Darren, I didn't state that the *order* was fuzzy, only many people's *understanding* of it. I just wanted to present some code that would let people visualize what was going on. Once you see it, the fog clears quickly. > > >Perlers talk about 'compile time' and 'run time', but in reality the two > >are very much mixed together. For example you can use BEGIN blocks to > >'run' code during 'compile' time, and eval blocks to 'compile' Perl > >during 'run' time. > > I disagree about them being mixed together. All code gets turned into > a parse tree during compile time. Then, to run the code, Perl walks the > parse tree executing the ops that it finds along the way. > > Perl does want to be quite the enabler though. :) It gives you hooks > so you can run code during compile time - why should the executable have > all the fun? That's the BEGIN statement. > > Perl also doesn't want to be discriminatory. It likes to enable you on > both sides of the compile/run phase. So, if in the middle of your > running code, you'd like to call the compiler again, you can do that > with eval. In other words, they are mixed together. Just because there's a parse tree involved, doesn't mean that there's a discrete compile time like in Java. Code can be added to the parse tree with 'require' at run time, and the parse tree can be executed before the so called compile time is done. In fact, you could write your entire working program in a BEGIN block and still have it *run* using 'perl -c'. > Well, CHECK is a compile-time directive as well but that's recent. > > >2) require Foo; > > is similar to: > > eval `cat Foo.pm`; > > It's actually significantly more complicated than that. The three You seemed to have missed the *spirit* of message. It was merely to have the reader look at Perl through a different set of glasses. Anyone who sets out to *define* Perl behaviour in an email message will fail miserably. Perl is that rich. That's why I like it. Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Thu Oct 12 12:31:30 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Modules - more than one object in file? References: <200010112214.AAA08946@muccpu1.muc.sdm.de> Message-ID: <39E5F572.7DF51607@activestate.com> Steffen Beyer wrote: > > Hello Todd Wells, in a previous mail you wrote: > > > I'm creating a module which uses some other objects internally, so I have > > multiple package statements in the same .pm file to define these other > > objects. Is there a good reason why I shouldn't do this? I'd prefer to > > keep it all in one file. However, I'm having a problem which I think is > > related. > > > > I have my module all in one file that contains 3 package statements, for > > objects A, B and C. e.g.: > > > > package A; > > sub new { blah } > > sub log { fooblah } > > 1; > > > > package B; > > @ISA = sq ( A ); > > sub new { blahblah } > > 1; > > > > package C; > > sub new { moblah } > > 1; > > > > However, when I call > > > > $pack_b = B->new(); > > $pack_b->log("foobar"), I get: > > > > Can't locate package "A" for @B::ISA at A.pm line 274. > > Can't locate package "A" for @B::ISA at A.pm line 274. > > Can't locate object method "log" via package "B" at A.pm line 274. > > Can't locate package "A" for @B::ISA. > > > > At the moment, my package "A" is just A.pm sitting in the same directory as > > the program which calls it. > > > > Is there a way to make this work or am I forced to put objects A, B and C in > > separate files? > > Since nobody was able to give you a difinitive answer so far, I'll try to give > my $0.02 as well - for what it's worth... :-) You should probably consult a few Perl manuals, a dictionary, and a shrink, before trying to give a "difinitive" answer about Perl. > > Apparently you have to prevent perl from searching the "B" and "C" modules > in the file system, where they cannot be located because they're no separate > files and since they're already in memory. This is entirely out of left field. Perl will only look for modules if you tell it to, through the 'require' or 'use' commands. (or 'do' or any number of hand-contrived methods that don't need discussion here :) BTW, 'B.pm' *is* a core module, and so actually *would* be found if Perl went looking for it. > Therefore you might have to inform perl that the modules are already in > memory. perl keeps track of this information in the reserved hash %INC - > not to be confused with @INC, the include path! > > Try this (at the bottom of "A.pm", before the final "1;"): > > $INC{'B.pm'} = $INC{'A.pm'}; > $INC{'C.pm'} = $INC{'A.pm'}; Beware of glittering pearls in a pit of hogwash. It is true that Perl keeps track of it's modules in %INC when they are require'd or use'd. But that's not the case here. The rest is hogwash. > > That should work if my extrapolation of how Perl works internally is > correct! :-) It's not. There are 2 reasons why a definitive answer was not given: 1) A definitive problem was not presented. 2) Much can be learned by discussing aspects of the problem, rather than just saying "You don't need to put your packages in separate files." (Which, BTW, happens to be true) Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From rathmore at bb12.betterbox.net Fri Oct 13 11:44:01 2000 From: rathmore at bb12.betterbox.net (rathmore@bb12.betterbox.net) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: FTP Problems Message-ID: I posted a similar questions to clpm, got a few suggestions but nothing that seems to satisfy my real problem. I'm going to post a summary of my question hear, hoping that it better explains what I need. And, btw, I'm a newbie to Perl, and I'm writting a program to run on NT. Problem: I'm having trouble with Net::FTP in that about 1 out of 5 times that I'm FTPing some files, my Perl program hangs. I don't get a time out, it just stops in the middle of downloading a file. This is a behind the scenes process so no one will be able to monitor it and do anything about it if it hangs. Question: Can I write something into the program to monitor the FTP process and if it doesn't complete in a given time frame, restart the FTP process? How would something like that look? Thanks! Rathmore - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jmcmill at n2h2.com Fri Oct 13 12:22:54 2000 From: jmcmill at n2h2.com (Jennifer McMillan) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: FWD: Damian sponsorship Message-ID: _____________________________________________________________ Date: Fri, 13 Oct 2000 16:29:23 +0100 To: "London.pm" Damian Conway sponsorship .... http://registration.yapc.org its not official and it hasn't got the fancy schmancy webpages yet, but this is where you can pledge/pay money The message: http://www.yetanother.org/damian/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dan at enic.cc Fri Oct 13 16:39:43 2000 From: dan at enic.cc (Dan Ebert) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Subroutine references with "strict refs" Message-ID: <4.3.2.7.0.20001013142642.00aed690@ns2.globaldns.com> Hello. I have a question for the group ... I am working a bit of code for a CGI script whose behavior is largely controlled by a hidden field "action" on the form being submitted. I am attempting to call a subroutine with the same name as the "action" parameter. Here is the snip of code: my $action = $in{action}; # $in{action} holds the value of the "action" parameter from the form. eval{ &$action; }; # error trap if ( ! $@ ){ &$action; } else { # do something with the error } This code works perfectly if I don't use strict; at the beginning of my code, but if I use strict; I get this error: Error: Can't use string ("remove") as a subroutine ref while "strict refs" in use at .... Any ideas? The only other way I come up with is using a "Dispatch table" hash of parameter->references-to-subroutines (as described on p 54 of O'Reilly's Advanced Perl Programing), but I'd rather not do that if possible. Thanks! -------------------------------------------------- The nice thing about standards is that there are so many of them to choose from. - Andrew S. Tanenbaum Dan Ebert eNIC Corporation, www.enic.cc -------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/archives/spug-list/attachments/20001013/10b14039/attachment.htm From ced at carios2.ca.boeing.com Fri Oct 13 17:15:35 2000 From: ced at carios2.ca.boeing.com (ced@carios2.ca.boeing.com) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Subroutine references with "strict refs" Message-ID: <200010132215.PAA02645@carios2.ca.boeing.com> > I am attempting to call a subroutine with the same name as the "action" > parameter. Here is the snip of code: > my $action = $in{action}; # $in{action} holds the value of the > "action" parameter from the form. > eval{ &$action; }; # error trap > if ( ! $@ ){ > &$action; > } > else { > # do something with the error > } > This code works perfectly if I don't use strict; at the beginning of my > code, but if I use strict; I get this error: > Error: Can't use string ("remove") as a subroutine ref while "strict refs" > in use at .... > Any ideas? The only other way I come up with is using a "Dispatch table" > hash of parameter->references-to-subroutines (as described on p 54 of > O'Reilly's Advanced Perl Programing), but I'd rather not do that if possible. There's much to be said for the dispatch table, but if you don't mind a slower runtime eval and a bit of do-it-yourself laundering, this'll pass strict: #-- launder the hidden param; ** See perldoc perlsec ** #-- explicitly allow only sub names unless ($action =~ /^(?:sub1|sub2|sub3|sub4)$/ ) { die "die evil sub passage...."; } eval "&$action"; if ( $@ ) { # do something with the error } hth, -- Charles DeRykus - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mike at unixgeek.net Fri Oct 13 17:32:26 2000 From: mike at unixgeek.net (Mike) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: OpenBSD Message-ID: <5.0.0.25.0.20001013153045.0178bba0@mail.winstar.com> Does anyone on the list use OpenBSD that could give me some help on it? I am trying to install it on an HP Vectra VL6 and it stops at rootdev= rrootdev= blah blah blah anyone know why? The boot disk and CD rom are both good. I have installed it sucesfully on an HP Vectra 8 and its fine. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From dan at enic.cc Fri Oct 13 18:36:41 2000 From: dan at enic.cc (Dan Ebert) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Subroutine references with "strict refs" In-Reply-To: <200010132215.PAA02645@carios2.ca.boeing.com> Message-ID: <4.3.2.7.0.20001013163620.00ae43a0@ns2.globaldns.com> Thanks, that seems to have done the trick. At 03:15 PM 10/13/00 -0700, ced@carios2.ca.boeing.com wrote: > > I am attempting to call a subroutine with the same name as the "action" > > parameter. Here is the snip of code: > > > > my $action = $in{action}; # $in{action} holds the value of the > > "action" parameter from the form. > > > eval{ &$action; }; # error trap > > if ( ! $@ ){ > > &$action; > > } > > else { > > # do something with the error > > } > > > This code works perfectly if I don't use strict; at the beginning of my > > code, but if I use strict; I get this error: > > > Error: Can't use string ("remove") as a subroutine ref while "strict refs" > > in use at .... > > > > Any ideas? The only other way I come up with is using a "Dispatch table" > > hash of parameter->references-to-subroutines (as described on p 54 of > > O'Reilly's Advanced Perl Programing), but I'd rather not do that if > possible. > >There's much to be said for the dispatch table, but if you >don't mind a slower runtime eval and a bit of do-it-yourself >laundering, this'll pass strict: > >#-- launder the hidden param; ** See perldoc perlsec ** >#-- explicitly allow only sub names > >unless ($action =~ /^(?:sub1|sub2|sub3|sub4)$/ ) { > die "die evil sub passage...."; >} >eval "&$action"; >if ( $@ ) { > # do something with the error >} > > >hth, >-- >Charles DeRykus > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ -------------------------------------------------- The nice thing about standards is that there are so many of them to choose from. - Andrew S. Tanenbaum Dan Ebert eNIC Corporation, www.enic.cc -------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jeremy at weezel.com Fri Oct 13 22:38:57 2000 From: jeremy at weezel.com (Jeremy Devenport) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Subroutine references with "strict refs" In-Reply-To: <4.3.2.7.0.20001013163620.00ae43a0@ns2.globaldns.com> Message-ID: If you're writing code like this you should definitely look at running with taint checking turned on. In particular the examples below are both big fat security holes. A small demo of why evaling user input is stupid/wrong: my $string = qq(foo; print "gotcha sucka\n"); sub foo { print qq(do the foo\n); } eval "&$string"; and even if you use the { block } form of eval: my $string = 'some_private_sub'; sub some_private_sub { print qq(nobody expects the spanish inquisition\n); } sub foo { print qq(do the foo\n); } eval { &$string }; (not quite as exploitable but still lets anybody run any already defined sub) The laundering will solve this security hole but you REALLY need to understand why you have to launder it. In short, what you really want to do is switch on the string passed to you, not magically interpret the user-input string into executable code. Jeremy -----Original Message----- From: owner-spug-list@pm.org [mailto:owner-spug-list@pm.org]On Behalf Of Dan Ebert Sent: Friday, October 13, 2000 4:37 PM To: ced@carios2.ca.boeing.com; spug-list@pm.org Subject: Re: SPUG: Subroutine references with "strict refs" Thanks, that seems to have done the trick. At 03:15 PM 10/13/00 -0700, ced@carios2.ca.boeing.com wrote: > > I am attempting to call a subroutine with the same name as the "action" > > parameter. Here is the snip of code: > > > > my $action = $in{action}; # $in{action} holds the value of the > > "action" parameter from the form. > > > eval{ &$action; }; # error trap > > if ( ! $@ ){ > > &$action; > > } > > else { > > # do something with the error > > } > > > This code works perfectly if I don't use strict; at the beginning of my > > code, but if I use strict; I get this error: > > > Error: Can't use string ("remove") as a subroutine ref while "strict refs" > > in use at .... > > > > Any ideas? The only other way I come up with is using a "Dispatch table" > > hash of parameter->references-to-subroutines (as described on p 54 of > > O'Reilly's Advanced Perl Programing), but I'd rather not do that if > possible. > >There's much to be said for the dispatch table, but if you >don't mind a slower runtime eval and a bit of do-it-yourself >laundering, this'll pass strict: > >#-- launder the hidden param; ** See perldoc perlsec ** >#-- explicitly allow only sub names > >unless ($action =~ /^(?:sub1|sub2|sub3|sub4)$/ ) { > die "die evil sub passage...."; >} >eval "&$action"; >if ( $@ ) { > # do something with the error >} > > >hth, >-- >Charles DeRykus > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ -------------------------------------------------- The nice thing about standards is that there are so many of them to choose from. - Andrew S. Tanenbaum Dan Ebert eNIC Corporation, www.enic.cc -------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Fri Oct 13 17:49:21 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: JoBs in Portland Message-ID: <20001013224921.A9016@timji.consultix.wa.com> Date: Mon, 25 Sep 2000 14:50:21 -0700 From: Daniel Chetlin Subject: [JOBS] Portland internet startup needs Perl programmers All, The below job posting is from my project manager -- we're looking for Perl people here in Lake Oswego (Portland area). If you're interested, send along a resume either to myself or to Ely, whose email is ely@ebizquality.com. Note that after doing some convincing of the big guys here, they've decided that it's OK for someone to only be in the office once a week or so -- so it'd be perfectly reasonable for someone to work from Seattle and drive down here for a meeting every Monday. If you have any questions about what we're doing here and whether your skills would fit, feel free to drop me a line. Thanks! -dlc ----------------------------------------------------------------------- I'm looking for a few good Perl programmers that are ready for a challenge. If you can put together Unix daemons, sling data between processes, consider SQL a close friend, and have a good background in OO coding, then I'd like to see your resume. Please note that I am not a recruiter; I'm the Project Manager here and I'll be working next door to you. Read the full details of our job openings at http://eBizQuality.com/work/ In a nutshell, our company is building a sophisticated network management system. Although we're well on our way, many of the parts of the system still need to be implemented -- so all your creativity will be well used. We're using Perl as our primary language to build this atop a distributed cluster of Linux and Solaris boxes. We're also planning on opensourcing some, if not all, of our fault tolerant application framework. We have some great people, a fantastic office environment, lots of industry links, and customers lining up to get our product. Also, if you become an employee here, you'll also get stock options and full benefits. What more could you possibly ask for? This is initially a contract (1099), full-time position with potential to move into a permanent position. The pay range is $25-75/hour, depending on your qualifications. While it is necessary to meet with the team on a regular basis, we are flexible on having you work in the office or at home, wherever is more suitable for you. Nevertheless, eBizQuality is located in a beautiful office building in Lake Oswego. Regards, Ely Shemesh -- eBizQuality, Inc. Making Your Web Better 1-503-603-1211 ely@eBizQuality.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Sat Oct 14 10:09:33 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: FTP Problems References: Message-ID: <0f0001c035f0$d8418690$790ff93f@adcom133> If you were on Unix, you would fork and exec a child process that starts the FTP. The parent would monitor it using kill 0 $pid. If the child was taking too long, the parent would kill it with kill SIGTERM $pid and spawn another child. Perl's fork function did not work on Windows as of last year, but ActiveState has been working on this. Check their latest release - it may be fixed. Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group Perl/SQL/Unix software engineering www.rayCosoft.com ----- Original Message ----- From: To: "Seattle Perl Users Group" Sent: Friday, October 13, 2000 9:44 AM Subject: SPUG: FTP Problems > I posted a similar questions to clpm, got a few suggestions but nothing > that seems to satisfy my real problem. I'm going to post a summary of my > question hear, hoping that it better explains what I need. And, btw, I'm a > newbie to Perl, and I'm writting a program to run on NT. > > Problem: > I'm having trouble with Net::FTP in that about 1 out of 5 times that I'm > FTPing some files, my Perl program hangs. I don't get a time out, it just > stops in the middle of downloading a file. This is a behind the scenes > process so no one will be able to monitor it and do anything about it if > it hangs. > > Question: > Can I write something into the program to monitor the FTP process and if > it doesn't complete in a given time frame, restart the FTP process? How > would something like that look? > > Thanks! > Rathmore > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Sat Oct 14 05:36:27 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Oct. Mtg: Slashcode ; Pop-up Date Windows Message-ID: <20001014033627.A1226@timji.consultix.wa.com> October 17, 2000 Seattle Perl Users Group Meeting ------------------------------------------------------------ Topics: Slashcode NG ; Pop-up Date/Time Windows in HTML Speakers: BRIAN AKER, VA Linux; JOE DEVLIN, Devlin Tech. Consulting Time: October 17th, 2000 (Third Tuesday), 7pm-9pm LOCATION: Union Bank of California Bldg, 5th Floor Mtg Room Cost: Free - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Brian Aker, Slashdot Senior Software Developer, VA Linux, will tell us about the new version of the Slashcode publishing system (code-named "Bender"), used in the slashdot.org and use.perl.org web sites, among others. It's written in Perl, of course. The new version includes a publishing system that features cached content, heavy integration with Apache via mod_perl, a standard API and module interface to write to, an interface to a rich templated display system, and a database independent backend. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Joe Devlin, of Devlin Technical Consulting, will give a brief talk about a Perl module he wrote that creates Date and Time pop-up windows in HTML format. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SPUG leader Tim Maher will give out some free books in a drawing, and help guide the discussions as usual. Admission is free and open to the general public. Attendees are encouraged to arrive at the building's 5th & Madison door by 6:45pm, which might be locked at other times. Parking We recommend avoiding the parking lot below the Union Bank building, due to the very hefty fee you'll be assessed if you leave after 9pm. There are plenty of other parking garages in the vicinity that are more affordable, and some on-street parking too. Pre/Post-Meeting Gathering Place Come and pass the pre-meeting time with other SPUGsters at the Rock Bottom brewpub, at 1333 5th Ave., (206) 623-3070, in downtown Seattle. Look to your left, near the bar or pool table, for bizarre yet strangely appealing characters wielding laptops and hearty ales. Attendees tend to arrive after 6pm, and to leave for the meeting by 6:40pm. For more information, including driving directions and street addresses, see http://www.halcyon.com/spug/. ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Sun Oct 15 22:03:19 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: FTP Problems References: <0f0001c035f0$d8418690$790ff93f@adcom133> Message-ID: <39EA6FF7.AF0D0418@activestate.com> Richard Anderson wrote: > Perl's fork function did not work on Windows as of last year, but > ActiveState > has been working on this. Check their latest release - it may be fixed. Perl supports fork emulation on Windows as of 5.6.0. Read 'perldoc perlfork', the top of which is shown below: NAME perlfork - Perl's fork() emulation SYNOPSIS Perl provides a fork() keyword that corresponds to the Unix system call of the same name. On most Unix-like platforms where the fork() system call is available, Perl's fork() simply calls it. On some platforms such as Windows where the fork() system call is not available, Perl can be built to emulate fork() at the interpreter level. While the emulation is designed to be as compatible as possible with the real fork() at the the level of the Perl program, there are certain important differences that stem from the fact that all the pseudo child "processes" created this way live in the same real process as far as the operating system is concerned. This document provides a general overview of the capabilities and limitations of the fork() emulation. Note that the issues discussed here are not applicable to platforms where a real fork() is available and Perl has been configured to use it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From keith at photoworks.com Mon Oct 16 12:27:40 2000 From: keith at photoworks.com (Keith Aaron) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Downloading perl stuff Message-ID: I posted the original question via one of the mailto links on ActiveState's website, and tried to elicit more info by replying via the mailto link Victor provides, but it always comes back as undeliverable ... so I'm posting the query to the group: ------------------------------------------------------------------------- This is good onfo, and I thank you very much ... but I have a couple more questions [I'm a *real* neophyte at this]: -how would I know (or find out) that Net::FTP translates to the 'libnet' module? -is there some sort of lookup available? -----Original Message----- From: Victor Sira [ ] Sent: None To: keith@photoworks.com Subject: Re: Installing a module (DPR#2404) Hello, ppm remove ppm install In your case: ppm remove/install libnet. Source code should be available off CPAN. Regards, Victor Sira ActiveState > How do I go about installing (or re-installing) a specific module/package > (eg, Net::FTP)? > > While we're at it, how do I look at the newest source for Net::FTP to see if > the bug I've encountered is fixed?? > -I don't know whether this bug was even reported; I just fixed it in the > source I downloaded > -Also, I didn't find a bug report with the text I searched for, but I'm not > sure I searched correctly > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/archives/spug-list/attachments/20001016/e0d71411/attachment.htm From tim at consultix-inc.com Tue Oct 17 01:43:13 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: October Meeting Today: Slashcode; Pop-Up Windows Message-ID: <20001017064313.A1168@timji.consultix.wa.com> October 17, 2000 Seattle Perl Users Group Meeting ------------------------------------------------------------ Topics: Slashcode NG ; Pop-up Date/Time Windows in HTML Speakers: BRIAN AKER, VA Linux; JOE DEVLIN, Devlin Tech. Consulting Time: October 17th, 2000 (Third Tuesday), 7pm-9pm LOCATION: Union Bank of California Bldg, 5th Floor Mtg Room Cost: Free - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Brian Aker, Slashdot Senior Software Developer, VA Linux, will tell us about the new version of the Slashcode publishing system (code-named "Bender"), used in the slashdot.org and use.perl.org web sites, among others. It's written in Perl, of course. The new version includes a publishing system that features cached content, heavy integration with Apache via mod_perl, a standard API and module interface to write to, an interface to a rich templated display system, and a database independent backend. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Joe Devlin, of Devlin Technical Consulting, will give a brief talk about a Perl module he wrote that creates Date and Time pop-up windows in HTML format. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SPUG leader Tim Maher will give out some free books in a drawing, and help guide the discussions as usual. ->UPDATE: Looks like Tim won't be able to make the meeting, so we'll hold off on the book drawing until next time. Admission is free and open to the general public. Attendees are encouraged to arrive at the building's 5th & Madison door by 6:45pm, which might be locked at other times. Parking We recommend avoiding the parking lot below the Union Bank building, due to the very hefty fee you'll be assessed if you leave after 9pm. There are plenty of other parking garages in the vicinity that are more affordable, and some on-street parking too. Pre/Post-Meeting Gathering Place Come and pass the pre-meeting time with other SPUGsters at the Rock Bottom brewpub, at 1333 5th Ave., (206) 623-3070, in downtown Seattle. Look to your left, near the bar or pool table, for bizarre yet strangely appealing characters wielding laptops and hearty ales. Attendees tend to arrive after 6pm, and to leave for the meeting by 6:40pm. For more information, including driving directions and street addresses, see http://www.halcyon.com/spug/. ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ ----- End forwarded message ----- -- *========================================================================* | Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# | | Email: tim@consultix-inc.com Web: http://www.consultix-inc.com | |Training- TIM MAHER: Unix, Perl DAMIAN CONWAY: Adv. Perl, OOP, Parsing | |CLASSES: 10/16-19: Int. Perl 10/23-25: Perl Programming 12/5-8: UNIX | *========================================================================* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Tue Oct 17 18:56:22 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Eastside Perl Message-ID: <20001017165622.A5682@xenon.cobaltgroup.com> If anyone's interested in presenting at next week's meeting on the Eastside (Redmond) let me know. Short presentations are welcome. Could be as short as 15 minutes. Here are some topic ideas: * How to start and maintain a CPAN module. * Talk about any Perl module that you like. http://search.cpan.org has pre-built documentation on all the modules so you can browse till you find something interesting. Here are some ideas: - XML::Simple - Convert XML into Perl's list-of-hashes type data structures. - VRML - How to create 3D models viewable in a VRML browser. - HTML::Template - Create HTML or other types of text from list-of-hashes type data structures. As powerful as JSP but simpler. - Test::Harness - How to write unit tests in Perl. - Getopt::Declare - Flexible easy command-line options in Perl. - Parse::RecDescent - Invent your own programming language in Perl. * Talk about something interesting from one of the Perl books out there. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Tue Oct 17 13:48:40 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: Eastside Perl; can it rise from ashes? Message-ID: <20001017184840.C2255@timji.consultix.wa.com> Asim Jalis says: >If anyone's interested in presenting at next week's meeting on the >Eastside (Redmond) let me know. >Short presentations are welcome. Could be as short as 15 minutes. Here >are some topic ideas: Folks, As the leader of SPUG, allow me to clue you in on a few realities of the Rise and Fall of special-interest User Groups. 1) If the group is willing to base its meeting schedule on the willingness of Vendors to make self-serving product presentations, it can limp along with a passive membership, if enough vendors can be found (although this would currently be impossible in the case of Perl). However, people attending such meetings will typically complain about the "hype/useful_info" ratio, and skip most of the meetings, making for a disjointed, and mostly disgruntled, membership. 2) If the Vendor/Sales-Pitch model is rejected, speakers must usually be obtained from the membership, which means if the group is comprised primarily of "Takers" (people who only want to benefit from the work of others), it will surely die. There must also be an appropriate proportion of "Givers", people who are willing to expend some effort for the benefit of the group as a whole. 3) Thus far, it looks like the Eastside population, which complained bitterly about the inconvenience of attending the (thriving) downtown-Seattle meetings and clamored for an Eastside location, is composed primarily of Takers (with one obvious exception being Asim, who is bravely trying to resuscitate E-SPUG from its moribund state). Unless people are willing to come forward to help create useful content for the meetings, E-SPUG will cease to exist, at least in its current form, and rightfully so. You should consider Asim's recent plea for speakers as a referendum on the future of E-SPUG, and if you want to keep this group alive, please volunteer to share something you know about Perl with the rest of the group at next Wednesday's meeting (10/25). -Tim ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From daniel at chetlin.com Thu Oct 19 05:30:24 2000 From: daniel at chetlin.com (Daniel Chetlin) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: JoBs in Portland In-Reply-To: <20001013224921.A9016@timji.consultix.wa.com>; from tim@consultix-inc.com on Fri, Oct 13, 2000 at 10:49:21PM +0000 References: <20001013224921.A9016@timji.consultix.wa.com> Message-ID: <20001019033024.D10448@darkstar.chetlin.org> On Fri, Oct 13, 2000 at 10:49:21PM +0000, Tim Maher/CONSULTIX wrote: > Date: Mon, 25 Sep 2000 14:50:21 -0700 > From: Daniel Chetlin > Subject: [JOBS] Portland internet startup needs Perl programmers > > All, > > The below job posting is from my project manager -- we're looking for > Perl people here in Lake Oswego (Portland area). If you're interested, > send along a resume either to myself or to Ely, whose email is > ely@ebizquality.com. Just to let you all know, Tim apparently accidentally posted this twice; the initial posting was three weeks or so ago, and we've made our hires at this point. I'm still interested in hearing about people who might be interested in a position in the future, as I'm sure we'll be doing more hiring soon, but at this point we're full up. Wanted to be sure no one got their hopes up. Thanks for your time! -dlc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jason at strangelight.com Mon Oct 23 18:50:51 2000 From: jason at strangelight.com (Jason Lamport) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: clever(?) new way to code CGI... Message-ID: As I was drifting off to sleep the other night, I got this brilliant idea. At least, I *think* it's a brilliant idea, but maybe it's one of those ideas that seem brilliant in theory, but end up being not so great when put into practice. So, I decided I'd share my idea here: to see if anyone had ever tried something similar, and if so, to hear what their experience was, and just to solicit general comments and wisdom from the group... BACKGROUND: One thing that's always seemed inelegant to me when coding CGI is the awkward mesh between the client-side code (HTML, plus maybe some JavaScript, VBScript, Java, etc.) and the server-side code (for those of us here on SPUG, this is presumably Perl, or a combination of Perl and something else). It's extremely difficult (or at least tedious) to embed sophisticated HTML layout directly into one's CGI code: it generally requires a lot of cutting and pasting between your WYSIWYG-ish HTML editor of choice and your source-code editor. The usual solution (for me, at least) has been to create separate HTML files -- using my favorite HTML editor -- which my CGI scripts then serve, usually modifying the HTML (i.e. adding dynamic content) in the process. This is still somewhat awkward, because it requires having at least two separate files, which are in different formats (HTML and Perl), are usually developed in two different application environments (HTML editor and source-code editor), and yet are *logically* intimately connected: the Perl code generally needs to "know" a great deal about the structure of the HTML document (e.g. the names of the form elements, perhaps their default values, and the possible values of radio, checkbox, and select elements, and where in the HTML code to insert dynamically-generated content). In short: it's awkward having the HTML code in one file, but all of the logic for manipulating and using that code in a separate file. Wouldn't it be cool if there were some sort of graphic, WYSIWIG-ish development environment for Perl CGI apps, so that both the Perl and the HTML code could be manipulated conveniently from within the same file? Or, to put it another way: wouldn't it be nice to embed HTML directly into your CGI scripts, yet still be able to edit that HTML directly, using a full-featured HTML editor? And now here's my brilliant idea: why not write Perl scripts which are *also* valid (or very nearly valid) HTML files? Example: ----------------foo.cgi-------------------------- #!/usr/bin/perl my $html_start=q| ... insert any amount of HTML here, just so long as it doesn't contain any pipe characters (and if it needs to include a |, just find a different char to use with the q quoting, or invent some sort of escape code like '__PIPE__' and do a s/__PIPE__/|/g on the string later on) ... '... __END__ --> ...insert any amount of HTML code here, which can be read by the Perl code above via the DATA handle... ---------------------EOF--------------------------- Other than the first two lines, this is a perfectly valid HTML file. Most HTML editors could handle this file no problem: they might complain slightly about those first two lines, but most are configurable so that they will leave those two lines alone. Even if you use a more Draconian HTML editor that insists on removing those first two lines, it would be easy enough to add them later in a text editor, or perhaps have a script that automatically adds those line when the files are uploaded to the server. There are dozens of useful variations on this idea: if one wants to have a chunk of WYSIWIG-editable HTML in the middle of one's Perl script, all one needs to write is some construct such as: ... q| --> ... this HTML will be visible and editable by your HTML editor.... ' ... $last_little_bit=<<''; --> ... more HTML code ... ---------------EOF---------------------- Now bar.html is a perfectly valid HTML file, which you can preview in any browser and should be editable in any HTML editor -- and it is *also*, in effect, a loadable Perl module (as long as you remember to use eval and to stick that little '$html_start=q|' in the front). One could combine this technique with AUTOLOAD and make all the "html" files in a certain directory accessible as simple function calls. And of course, since the whole point of these techniques is encapsulation, the obvious next step is to make these files behave like objects, with a full OO interface... As you can see, the examples I've given above are *extremely* skeletal, but I hope I've communicated the gist of where I'm going with this. Has anyone tried a system like this for doing CGI programming? Any thoughts, reactions, criticisms? Does anyone else find this idea as exciting as I do? Or is this really specific to my own idiosyncratic coding style, and utterly useless to everyone else? -jason - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From aaron at activox.com Mon Oct 23 19:47:16 2000 From: aaron at activox.com (Aaron Salo) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: clever(?) new way to code CGI... In-Reply-To: Message-ID: <3.0.5.32.20001023174716.00a66100@127.0.0.1> Might want to look into embperl or HTML::Template if you tire of reinventing the wheel. The first embeds perl code into your HTML docs at the cost of parsing your docs. The second makes presentation independent of the cgi code. Depending on which you find more soothing. Both have their merits. HTML::Template is particularly nice for keeping the frosting folks out from underfoot whilst you program. ~!a At 04:50 PM 10/23/00 -0700, Jason Lamport wrote: >And now here's my brilliant idea: why not write Perl scripts which >are *also* valid (or very nearly valid) HTML files? Example: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Mon Oct 23 22:03:31 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: clever(?) new way to code CGI... References: Message-ID: <009001c03d67$002bcc10$6d0ff93f@adcom133> Numerous people have addressed this issue. A partial listing of the options I know about: HTML::Template (simple, but effective) Text::Template (more powerful) HTML::Mason (comprehensive) No need to reinvent the wheel until you have worked with these modules and have a clear reason why they don't serve your needs. Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group Perl/SQL/Unix software engineering www.rayCosoft.com (corporate) www.zipcon.net/~starfire/home (personal) ----- Original Message ----- From: "Jason Lamport" To: Sent: Monday, October 23, 2000 4:50 PM Subject: SPUG: clever(?) new way to code CGI... > As I was drifting off to sleep the other night, I got this brilliant > idea. At least, I *think* it's a brilliant idea, but maybe it's one > of those ideas that seem brilliant in theory, but end up being not so > great when put into practice. So, I decided I'd share my idea here: > to see if anyone had ever tried something similar, and if so, to hear > what their experience was, and just to solicit general comments and > wisdom from the group... > > BACKGROUND: > One thing that's always seemed inelegant to me when coding CGI is the > awkward mesh between the client-side code (HTML, plus maybe some > JavaScript, VBScript, Java, etc.) and the server-side code (for those > of us here on SPUG, this is presumably Perl, or a combination of Perl > and something else). > > It's extremely difficult (or at least tedious) to embed sophisticated > HTML layout directly into one's CGI code: it generally requires a lot > of cutting and pasting between your WYSIWYG-ish HTML editor of choice > and your source-code editor. > > The usual solution (for me, at least) has been to create separate > HTML files -- using my favorite HTML editor -- which my CGI scripts > then serve, usually modifying the HTML (i.e. adding dynamic content) > in the process. This is still somewhat awkward, because it requires > having at least two separate files, which are in different formats > (HTML and Perl), are usually developed in two different application > environments (HTML editor and source-code editor), and yet are > *logically* intimately connected: the Perl code generally needs to > "know" a great deal about the structure of the HTML document (e.g. > the names of the form elements, perhaps their default values, and the > possible values of radio, checkbox, and select elements, and where in > the HTML code to insert dynamically-generated content). In short: > it's awkward having the HTML code in one file, but all of the logic > for manipulating and using that code in a separate file. > > Wouldn't it be cool if there were some sort of graphic, WYSIWIG-ish > development environment for Perl CGI apps, so that both the Perl and > the HTML code could be manipulated conveniently from within the same > file? Or, to put it another way: wouldn't it be nice to embed HTML > directly into your CGI scripts, yet still be able to edit that HTML > directly, using a full-featured HTML editor? > > And now here's my brilliant idea: why not write Perl scripts which > are *also* valid (or very nearly valid) HTML files? Example: > > ----------------foo.cgi-------------------------- > #!/usr/bin/perl > my $html_start=q| > > > ... insert any amount of HTML here, just so long as it doesn't > contain any pipe characters (and if it needs to include a |, just > find a different char to use with the q quoting, or invent some sort > of escape code like '__PIPE__' and do a s/__PIPE__/|/g on the string > later on) ... > > '... > > __END__ > > --> ...insert any amount of HTML code here, which can be read by the > Perl code above via the DATA handle... > > ---------------------EOF--------------------------- > > Other than the first two lines, this is a perfectly valid HTML file. > Most HTML editors could handle this file no problem: they might > complain slightly about those first two lines, but most are > configurable so that they will leave those two lines alone. Even if > you use a more Draconian HTML editor that insists on removing those > first two lines, it would be easy enough to add them later in a text > editor, or perhaps have a script that automatically adds those line > when the files are uploaded to the server. > > There are dozens of useful variations on this idea: if one wants to > have a chunk of WYSIWIG-editable HTML in the middle of one's Perl > script, all one needs to write is some construct such as: > > ... q| --> > > ... this HTML will be visible and editable by your HTML editor.... > > ' ... > > $last_little_bit=<<''; > --> > ... more HTML code ... > > ---------------EOF---------------------- > > Now bar.html is a perfectly valid HTML file, which you can preview in > any browser and should be editable in any HTML editor -- and it is > *also*, in effect, a loadable Perl module (as long as you remember to > use eval and to stick that little '$html_start=q|' in the front). > One could combine this technique with AUTOLOAD and make all the > "html" files in a certain directory accessible as simple function > calls. And of course, since the whole point of these techniques is > encapsulation, the obvious next step is to make these files behave > like objects, with a full OO interface... > > As you can see, the examples I've given above are *extremely* > skeletal, but I hope I've communicated the gist of where I'm going > with this. Has anyone tried a system like this for doing CGI > programming? Any thoughts, reactions, criticisms? Does anyone else > find this idea as exciting as I do? Or is this really specific to my > own idiosyncratic coding style, and utterly useless to everyone else? > > -jason > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jeff at planetoid.net Mon Oct 23 22:50:38 2000 From: jeff at planetoid.net (jeff saenz) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: clever(?) new way to code CGI... References: <009001c03d67$002bcc10$6d0ff93f@adcom133> Message-ID: <39F5070E.DBC22B72@planetoid.net> There was a lengthy heated discussion on the mod_perl mailing list a few months back debating the usefulness of each solution. I believe someone was planning to put together a detailed comparison chart. Try perl.apache.org or the mailing list. Richard Anderson wrote: > Numerous people have addressed this issue. A partial listing of the options > I know about: > > HTML::Template (simple, but effective) > Text::Template (more powerful) > HTML::Mason (comprehensive) > > No need to reinvent the wheel until you have worked with these modules and > have a clear reason why they don't serve your needs. > > Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group > Perl/SQL/Unix software engineering www.rayCosoft.com (corporate) > www.zipcon.net/~starfire/home (personal) Jeff Saenz http://www.planetoid.net jeff@planetoid.net - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From rick at libronix.com Tue Oct 24 00:36:13 2000 From: rick at libronix.com (Rick Brannan) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: MSXML & Perl Message-ID: <9F418E3BB85BD411A8940008C7DF73EE08C67B@smtp.logos.com> For folks on Windows platforms (like me): Have you ever experimented with using Win32::OLE and Microsoft's MSXML? It offers compiled code that quickly loads things into the DOM and allows you to do all sorts of funky stuff with XSL/XPATH queries. Consider the below extremely simplified xml: element 1 content element 2 content element 3 content And a very simple example: #-------------------------------- use Win32::OLE; # UTF-8 stuff in perl 5.0?? builds # (I don't have ActiveState's 5.6 installed yet) $Win32::OLE::CP = CP_UTF8; my $xmlFile = "myxml.xml"; my $xmlDom = new Win32::OLE 'Microsoft.XMLDOM' or warn "$!"; # don't worry about asyncronous access locally ... $xmlDom->{async} = "False"; # load it. $xmlDom->load($xmlFile); # get the elements my $elements = $xmlDom->selectNodes("/root/element"); foreach my $nCount (0 .. ($elements->length - 1)) { my $elementContent = $elements->item($nCount)->{text}; print "\nContent: $elementContent"; } #-------------------------------- Output: C:\temp\xml>perl temp.pl Content: element 1 content Content: element 2 content Content: element 3 content Basically, anything you could do with MSXML in JavaScript/VBScript/etc. you can do with Perl too. I initially ran across this when converting someone else's existing JavaScript stuff to Perl so I could have access to Perl's regex superiority, and ever since then this has been my latest hammer, and all my data have conveinently transformed into nails. I've got some 3-5 meg XML files that load into the DOM *very* quickly and then allow me to run all sorts of interesting and somewhat twisted queries on the data using XPATH syntax. More info on the available XMLDOM methods/properties and XPATH syntax is available on MSDN (msdn.microsoft.com/xml). I have had some problems with munging of unicode data (Russian, specifically, though German and Spanish seem to be all right) but I think 5.6 will fix that. Note that MSXML returns UTF-8 by default. Hope it helps. I know I've found it handy. Now, back to lurk mode ... hopefully I haven't stirred the 'M$ is evil' crowd. ----------------------------------------- Rick Brannan -- rick@libronix.com Book Design Manager, Libronix Corp. http://www.libronix.com "Unless Scripture is studied and preached with diligence, Christians will not know what God requires of them." -- E.J. Carnell - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jason at strangelight.com Tue Oct 24 01:02:10 2000 From: jason at strangelight.com (Jason Lamport) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: clever(?) new way to code CGI... In-Reply-To: <009001c03d67$002bcc10$6d0ff93f@adcom133> References: <009001c03d67$002bcc10$6d0ff93f@adcom133> Message-ID: I find these responses very interesting, though slightly puzzling. I've looked at these modules, and *to me* they all seem to suffer from precisely the awkwardness that my idea is meant to avoid. In some ways, they seem to me to make the situation even worse: it's bad enough that I've got to mesh HTML and Perl -- the last thing I want to do is to then add some module with its own idiosyncratic API, effectively requiring me to throw YET ANOTHER mini language into the mix. I have certainly done my share of wheel-reinventing: I long ago coded modules that do most of what HTML::Template and Text::Template do, and probably a few things that even HTML::Mason doesn't do (though I confess, I haven't read those docs in their entirety). The *functionality* is not what I find so interesting about my suggestion. I found my idea so exciting because it seems to me like a simpler and far more flexible way of doing these things, and many fancier things as well, and one that allows me *easily* to design my own API's, rather than being forced to use someone else's. It seemed to me that in this case, I had found a way around my usual CPAN dilemma: use a CPAN module which does *almost* what I want, or put in some extra time and effort "reinventing the wheel" to create my own module which does *exactly* what I want. In this case, it seems to me that I've discovered a system with which I can effectively create modules that do exactly what I want, and do so with less effort than it would take me to download a CPAN module and learn its API. Judging from these responses, however, I suspect that this is completely relative to my own programming style, and apparently not as much use to others on the list as I had hoped. And again, this is all still just theoretical: I haven't actually coded any sites using these techniques yet. I'll try it out, and if it works as well as I hope, maybe I'll come back with something of more general interest to share... -jason At 8:03 PM -0700 10/23/00, Richard Anderson wrote: >Numerous people have addressed this issue. A partial listing of the options >I know about: > >HTML::Template (simple, but effective) >Text::Template (more powerful) >HTML::Mason (comprehensive) > >No need to reinvent the wheel until you have worked with these modules and >have a clear reason why they don't serve your needs. > >Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group >Perl/SQL/Unix software engineering www.rayCosoft.com (corporate) >www.zipcon.net/~starfire/home (personal) >----- Original Message ----- >From: "Jason Lamport" >To: >Sent: Monday, October 23, 2000 4:50 PM >Subject: SPUG: clever(?) new way to code CGI... > > >> As I was drifting off to sleep the other night, I got this brilliant >> idea. At least, I *think* it's a brilliant idea, but maybe it's one >> of those ideas that seem brilliant in theory, but end up being not so >> great when put into practice. So, I decided I'd share my idea here: >> to see if anyone had ever tried something similar, and if so, to hear >> what their experience was, and just to solicit general comments and >> wisdom from the group... >> >> BACKGROUND: >> One thing that's always seemed inelegant to me when coding CGI is the >> awkward mesh between the client-side code (HTML, plus maybe some >> JavaScript, VBScript, Java, etc.) and the server-side code (for those >> of us here on SPUG, this is presumably Perl, or a combination of Perl >> and something else). >> >> It's extremely difficult (or at least tedious) to embed sophisticated >> HTML layout directly into one's CGI code: it generally requires a lot >> of cutting and pasting between your WYSIWYG-ish HTML editor of choice >> and your source-code editor. >> >> The usual solution (for me, at least) has been to create separate >> HTML files -- using my favorite HTML editor -- which my CGI scripts >> then serve, usually modifying the HTML (i.e. adding dynamic content) > > in the process. This is still somewhat awkward, because it requires >> having at least two separate files, which are in different formats >> (HTML and Perl), are usually developed in two different application >> environments (HTML editor and source-code editor), and yet are >> *logically* intimately connected: the Perl code generally needs to >> "know" a great deal about the structure of the HTML document (e.g. >> the names of the form elements, perhaps their default values, and the >> possible values of radio, checkbox, and select elements, and where in >> the HTML code to insert dynamically-generated content). In short: >> it's awkward having the HTML code in one file, but all of the logic >> for manipulating and using that code in a separate file. >> >> Wouldn't it be cool if there were some sort of graphic, WYSIWIG-ish >> development environment for Perl CGI apps, so that both the Perl and >> the HTML code could be manipulated conveniently from within the same >> file? Or, to put it another way: wouldn't it be nice to embed HTML >> directly into your CGI scripts, yet still be able to edit that HTML >> directly, using a full-featured HTML editor? >> >> And now here's my brilliant idea: why not write Perl scripts which >> are *also* valid (or very nearly valid) HTML files? Example: >> >> ----------------foo.cgi-------------------------- >> #!/usr/bin/perl >> my $html_start=q| >> >> >> ... insert any amount of HTML here, just so long as it doesn't >> contain any pipe characters (and if it needs to include a |, just >> find a different char to use with the q quoting, or invent some sort >> of escape code like '__PIPE__' and do a s/__PIPE__/|/g on the string >> later on) ... >> >> '... >> >> __END__ >> >> --> ...insert any amount of HTML code here, which can be read by the >> Perl code above via the DATA handle... >> >> ---------------------EOF--------------------------- >> >> Other than the first two lines, this is a perfectly valid HTML file. >> Most HTML editors could handle this file no problem: they might >> complain slightly about those first two lines, but most are >> configurable so that they will leave those two lines alone. Even if >> you use a more Draconian HTML editor that insists on removing those >> first two lines, it would be easy enough to add them later in a text >> editor, or perhaps have a script that automatically adds those line >> when the files are uploaded to the server. >> >> There are dozens of useful variations on this idea: if one wants to >> have a chunk of WYSIWIG-editable HTML in the middle of one's Perl >> script, all one needs to write is some construct such as: >> >> ... q| --> >> >> ... this HTML will be visible and editable by your HTML editor.... >> >> ' ... >> >> $last_little_bit=<<''; >> --> >> ... more HTML code ... >> >> ---------------EOF---------------------- >> >> Now bar.html is a perfectly valid HTML file, which you can preview in >> any browser and should be editable in any HTML editor -- and it is >> *also*, in effect, a loadable Perl module (as long as you remember to >> use eval and to stick that little '$html_start=q|' in the front). >> One could combine this technique with AUTOLOAD and make all the > > "html" files in a certain directory accessible as simple function >> calls. And of course, since the whole point of these techniques is >> encapsulation, the obvious next step is to make these files behave >> like objects, with a full OO interface... >> >> As you can see, the examples I've given above are *extremely* >> skeletal, but I hope I've communicated the gist of where I'm going >> with this. Has anyone tried a system like this for doing CGI >> programming? Any thoughts, reactions, criticisms? Does anyone else >> find this idea as exciting as I do? Or is this really specific to my >> own idiosyncratic coding style, and utterly useless to everyone else? >> >> -jason >> >> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >> POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org >> Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL >> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address >> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest >> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ >> >> >> > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Tue Oct 24 08:42:08 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: clever(?) new way to code CGI... References: <009001c03d67$002bcc10$6d0ff93f@adcom133> Message-ID: <00c501c03dc0$36bd3a80$6d0ff93f@adcom133> It's a matter of making the most effective use of your time. Any module that offers complex functionality is necessarily going to have a complex API. I do agree that most CPAN modules have inadequate documentation, but since they always come with source code I can usually figure them out in much less time than it takes to reproduce the code "my way". I found the interface for HTML::Template to be very simple, and I learned it in less than an hour. The other benefit of using CPAN modules is that the more popular ones are often upgraded and maintained over the years. It's like free candy. If you feel a module is inadequate but useful, you can modify it to work the way you want, then send the new code to the author for incorporation. If the author doesn't like your mods, you can release your version as a new CPAN module. CPAN is one of the things that makes Perl great, and I feel it is in my self-interest to support it. Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group Perl/SQL/Unix software engineering www.rayCosoft.com (corporate) www.zipcon.net/~starfire/home (personal) ----- Original Message ----- From: "Jason Lamport" To: ; "Jason Lamport" Sent: Monday, October 23, 2000 11:02 PM Subject: Re: SPUG: Re: clever(?) new way to code CGI... > I find these responses very interesting, though slightly puzzling. > I've looked at these modules, and *to me* they all seem to suffer > from precisely the awkwardness that my idea is meant to avoid. In > some ways, they seem to me to make the situation even worse: it's bad > enough that I've got to mesh HTML and Perl -- the last thing I want > to do is to then add some module with its own idiosyncratic API, > effectively requiring me to throw YET ANOTHER mini language into the > mix. > > I have certainly done my share of wheel-reinventing: I long ago coded > modules that do most of what HTML::Template and Text::Template do, > and probably a few things that even HTML::Mason doesn't do (though I > confess, I haven't read those docs in their entirety). The > *functionality* is not what I find so interesting about my > suggestion. I found my idea so exciting because it seems to me like > a simpler and far more flexible way of doing these things, and many > fancier things as well, and one that allows me *easily* to design my > own API's, rather than being forced to use someone else's. > > It seemed to me that in this case, I had found a way around my usual > CPAN dilemma: use a CPAN module which does *almost* what I want, or > put in some extra time and effort "reinventing the wheel" to create > my own module which does *exactly* what I want. In this case, it > seems to me that I've discovered a system with which I can > effectively create modules that do exactly what I want, and do so > with less effort than it would take me to download a CPAN module and > learn its API. > > Judging from these responses, however, I suspect that this is > completely relative to my own programming style, and apparently not > as much use to others on the list as I had hoped. And again, this is > all still just theoretical: I haven't actually coded any sites using > these techniques yet. I'll try it out, and if it works as well as I > hope, maybe I'll come back with something of more general interest to > share... > > -jason > > > At 8:03 PM -0700 10/23/00, Richard Anderson wrote: > >Numerous people have addressed this issue. A partial listing of the options > >I know about: > > > >HTML::Template (simple, but effective) > >Text::Template (more powerful) > >HTML::Mason (comprehensive) > > > >No need to reinvent the wheel until you have worked with these modules and > >have a clear reason why they don't serve your needs. > > > >Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group > >Perl/SQL/Unix software engineering www.rayCosoft.com (corporate) > >www.zipcon.net/~starfire/home (personal) > >----- Original Message ----- > >From: "Jason Lamport" > >To: > >Sent: Monday, October 23, 2000 4:50 PM > >Subject: SPUG: clever(?) new way to code CGI... > > > > > >> As I was drifting off to sleep the other night, I got this brilliant > >> idea. At least, I *think* it's a brilliant idea, but maybe it's one > >> of those ideas that seem brilliant in theory, but end up being not so > >> great when put into practice. So, I decided I'd share my idea here: > >> to see if anyone had ever tried something similar, and if so, to hear > >> what their experience was, and just to solicit general comments and > >> wisdom from the group... > >> > >> BACKGROUND: > >> One thing that's always seemed inelegant to me when coding CGI is the > >> awkward mesh between the client-side code (HTML, plus maybe some > >> JavaScript, VBScript, Java, etc.) and the server-side code (for those > >> of us here on SPUG, this is presumably Perl, or a combination of Perl > >> and something else). > >> > >> It's extremely difficult (or at least tedious) to embed sophisticated > >> HTML layout directly into one's CGI code: it generally requires a lot > >> of cutting and pasting between your WYSIWYG-ish HTML editor of choice > >> and your source-code editor. > >> > >> The usual solution (for me, at least) has been to create separate > >> HTML files -- using my favorite HTML editor -- which my CGI scripts > >> then serve, usually modifying the HTML (i.e. adding dynamic content) > > > in the process. This is still somewhat awkward, because it requires > >> having at least two separate files, which are in different formats > >> (HTML and Perl), are usually developed in two different application > >> environments (HTML editor and source-code editor), and yet are > >> *logically* intimately connected: the Perl code generally needs to > >> "know" a great deal about the structure of the HTML document (e.g. > >> the names of the form elements, perhaps their default values, and the > >> possible values of radio, checkbox, and select elements, and where in > >> the HTML code to insert dynamically-generated content). In short: > >> it's awkward having the HTML code in one file, but all of the logic > >> for manipulating and using that code in a separate file. > >> > >> Wouldn't it be cool if there were some sort of graphic, WYSIWIG-ish > >> development environment for Perl CGI apps, so that both the Perl and > >> the HTML code could be manipulated conveniently from within the same > >> file? Or, to put it another way: wouldn't it be nice to embed HTML > >> directly into your CGI scripts, yet still be able to edit that HTML > >> directly, using a full-featured HTML editor? > >> > >> And now here's my brilliant idea: why not write Perl scripts which > >> are *also* valid (or very nearly valid) HTML files? Example: > >> > >> ----------------foo.cgi-------------------------- > >> #!/usr/bin/perl > >> my $html_start=q| > >> > >> > >> ... insert any amount of HTML here, just so long as it doesn't > >> contain any pipe characters (and if it needs to include a |, just > >> find a different char to use with the q quoting, or invent some sort > >> of escape code like '__PIPE__' and do a s/__PIPE__/|/g on the string > >> later on) ... > >> > >> '... > >> > >> __END__ > >> > >> --> ...insert any amount of HTML code here, which can be read by the > >> Perl code above via the DATA handle... > >> > >> ---------------------EOF--------------------------- > >> > >> Other than the first two lines, this is a perfectly valid HTML file. > >> Most HTML editors could handle this file no problem: they might > >> complain slightly about those first two lines, but most are > >> configurable so that they will leave those two lines alone. Even if > >> you use a more Draconian HTML editor that insists on removing those > >> first two lines, it would be easy enough to add them later in a text > >> editor, or perhaps have a script that automatically adds those line > >> when the files are uploaded to the server. > >> > >> There are dozens of useful variations on this idea: if one wants to > >> have a chunk of WYSIWIG-editable HTML in the middle of one's Perl > >> script, all one needs to write is some construct such as: > >> > >> ... q| --> > >> > >> ... this HTML will be visible and editable by your HTML editor.... > >> > >> ' ... > >> > >> $last_little_bit=<<''; > >> --> > >> ... more HTML code ... > >> > >> ---------------EOF---------------------- > >> > >> Now bar.html is a perfectly valid HTML file, which you can preview in > >> any browser and should be editable in any HTML editor -- and it is > >> *also*, in effect, a loadable Perl module (as long as you remember to > >> use eval and to stick that little '$html_start=q|' in the front). > >> One could combine this technique with AUTOLOAD and make all the > > > "html" files in a certain directory accessible as simple function > >> calls. And of course, since the whole point of these techniques is > >> encapsulation, the obvious next step is to make these files behave > >> like objects, with a full OO interface... > >> > >> As you can see, the examples I've given above are *extremely* > >> skeletal, but I hope I've communicated the gist of where I'm going > >> with this. Has anyone tried a system like this for doing CGI > >> programming? Any thoughts, reactions, criticisms? Does anyone else > >> find this idea as exciting as I do? Or is this really specific to my > >> own idiosyncratic coding style, and utterly useless to everyone else? > >> > >> -jason > >> > >> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > >> POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > >> Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > >> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > >> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > >> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > >> > >> > >> > > > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From Showell30 at aol.com Tue Oct 24 10:59:17 2000 From: Showell30 at aol.com (Showell30@aol.com) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Perl and HTML Message-ID: <4d.281e529.27270bd6@aol.com> Since Jason has opened up the topic of Perl and HTML, I will throw my two cents in. I am working on a project where I have a bunch of web pages with family/vacation photos that I need to tie together, giving them common look-and-feel, common table of contents, etc. I considered a template approach, and decided against it for a a couple reasons: 1) If your template solution does not have an "include" feature, it can be difficult to reuse HTML. 2) If you do use the "include" feature, you can quickly have a bunch of files hanging around, which gets to be a mess after a while. 3) I've done template solutions before that were ugly (non-Perl, though). 4) I think of data first, presentation second, so templates just seemed wrong for my coding psychology. 5) This is a personal project, so I can afford to be lazy and wrong about it. ;) Anyway, I decided to use HTML::Subs and HTML::Entities instead. I have found those to be very smooth sailing. Here is what I like: 1) Code is prettier -- no matching of start and end tags (although some would argue matching parens is just as bad). 2) Reuse scheme is more Perlish to me. If I have a cool way of laying out a table, I share it by making a subroutine to return the table widget, whereas a template solution might lend itself to having an include file. 3) My approach does not preclude templates in the future. I do 90% of my HTML through Perl subroutines, but sometimes it's easier just to code up a little raw HTML, and I either do that as a here document, or I slurp it in from a file, and then I use HTML::TreeBuilder to stick it into my HTML::Entities tree. Having said all this, I must say that a friend of mine has done a very similar project w/posting photos to the web, and he went the template approach. He went with (gasp) ASP, and I must say, his code looks pretty clean and maintainable. Also, at the last SPUG meeting, the slashcode guy says that they have been happy with the template solution. Even so, I am content with my non-templates solution. If you do go the Subs/Entities route, here are some headaches that you might encounter: 1) Tr for table rows can trip you up, if you don't realize it's a reserved word in Perl. This is well documented, but I got tripped up on it any way. 2) It seems hard to get  's into the page, without them being overtranslated. The workaround is easy, though. 3) Mixing raw HTML into the Subs/Entities data structure was tough for me at first. In the end, I wrote like a three line function that used TreeBuilder to solve the problem, but I wish this had been documented better, or if there is an even simpler way, I wish it were documented more clearly. One last thought for Jason -- check out the Data::Locations module. Even if you don't use it for HTML, it's great food for thought. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jeff at planetoid.net Tue Oct 24 13:00:46 2000 From: jeff at planetoid.net (jeff saenz) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: clever(?) new way to code CGI... References: <009001c03d67$002bcc10$6d0ff93f@adcom133> <00c501c03dc0$36bd3a80$6d0ff93f@adcom133> Message-ID: <39F5CE4D.2F6FA8EA@planetoid.net> What about xml based presentation management systems? Can they replace html template and page scripting systems? And what about CSS? -- Jeff Saenz (jeff@planetoid.net) Perl/SQL/Unix software engineering http://www.planetoid.net - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Tue Oct 24 13:33:39 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: clever(?) new way to code CGI... References: <009001c03d67$002bcc10$6d0ff93f@adcom133> <00c501c03dc0$36bd3a80$6d0ff93f@adcom133> Message-ID: <39F5D603.B6A6E205@activestate.com> Richard Anderson wrote: > > It's a matter of making the most effective use of your time. Any module > that offers complex functionality is necessarily going to have a complex > API. Richard, Not necessarily. Modules can offer a lot of DWIMity instead of a complex API. (Inline.pm for example :-) Maybe Jason could write a template module that "Does what I mean". The whole cgi templating issue is a very tough nut that I believe has not been completely cracked. That's why there are soooo many modules that have tried. > I do agree that most CPAN modules have inadequate documentation, but > since they always come with source code I can usually figure them out in > much less time than it takes to reproduce the code "my way". > > I found the interface for HTML::Template to be very simple, and I learned it > in less than an hour. > > The other benefit of using CPAN modules is that the more popular ones are > often upgraded and maintained over the years. It's like free candy. > > If you feel a module is inadequate but useful, you can modify it to work the > way you want, then send the new code to the author for incorporation. If > the author doesn't like your mods, you can release your version as a new > CPAN module. Jason, I definitely agree that the CPAN is the place to start. 2 years ago I wrote my own templating module only to discover that MJD had done exactly what I had intended, only much better. I immediately switched to his version. (At the very least, it saved me from having to write doc :) But if everything out there leaves you dry, please give the nut another crack. I'm sure that our group would be glad to review it for you. > > CPAN is one of the things that makes Perl great, and I feel it is in my > self-interest to support it. SPUG, Amen. It is of interest to note, that my initial work at ActiveState is in making our CPAN related offerings better. Now would be a fine time for you SPUGsters to voice your opinions about that. ,Brian -- perl -e 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf ("Just Another %s Hacker\\n",x);}};print JAxH+Perl' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From burkenholt at home.com Tue Oct 24 13:38:11 2000 From: burkenholt at home.com (Tim Holt) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: Perl and HTML References: <4d.281e529.27270bd6@aol.com> Message-ID: <003701c03de9$907c1860$8aa40c18@crvlls1.or.home.com> At least for me, it all depends on if you want to see what you're doing as HTML with code in it, or code with HTML in it. Using a hybrid system, where code is embedded IN the HTML (as opposed to HTML embedded in the language) is far easier to manage for some projects. PHP's been great for this by me. Anyone have any experiences with embedded Perl? ----- Original Message ----- From: To: Sent: Tuesday, October 24, 2000 8:59 AM Subject: SPUG: Perl and HTML > Since Jason has opened up the topic of Perl and HTML, I will throw my two > cents in. > > I am working on a project where I have a bunch of web pages with > family/vacation photos that I need to tie together, giving them common > look-and-feel, common table of contents, etc. > > I considered a template approach, and decided against it for a a couple > reasons: > > 1) If your template solution does not have an "include" feature, it can be > difficult to reuse HTML. > 2) If you do use the "include" feature, you can quickly have a bunch of files > hanging around, which gets to be a mess after a while. > 3) I've done template solutions before that were ugly (non-Perl, though). > 4) I think of data first, presentation second, so templates just seemed wrong > for my coding psychology. > 5) This is a personal project, so I can afford to be lazy and wrong about it. > ;) > > Anyway, I decided to use HTML::Subs and HTML::Entities instead. I have found > those to be very smooth sailing. Here is what I like: > > 1) Code is prettier -- no matching of start and end tags (although some would > argue matching parens is just as bad). > 2) Reuse scheme is more Perlish to me. If I have a cool way of laying out a > table, I share it by making a subroutine to return the table widget, whereas > a template solution might lend itself to having an include file. > 3) My approach does not preclude templates in the future. I do 90% of my > HTML through Perl subroutines, but sometimes it's easier just to code up a > little raw HTML, and I either do that as a here document, or I slurp it in > from a file, and then I use HTML::TreeBuilder to stick it into my > HTML::Entities tree. > > Having said all this, I must say that a friend of mine has done a very > similar project w/posting photos to the web, and he went the template > approach. He went with (gasp) ASP, and I must say, his code looks pretty > clean and maintainable. Also, at the last SPUG meeting, the slashcode guy > says that they have been happy with the template solution. Even so, I am > content with my non-templates solution. > > If you do go the Subs/Entities route, here are some headaches that you might > encounter: > > 1) Tr for table rows can trip you up, if you don't realize it's a reserved > word in Perl. This is well documented, but I got tripped up on it any way. > 2) It seems hard to get  's into the page, without them being > overtranslated. The workaround is easy, though. > 3) Mixing raw HTML into the Subs/Entities data structure was tough for me at > first. In the end, I wrote like a three line function that used TreeBuilder > to solve the problem, but I wish this had been documented better, or if there > is an even simpler way, I wish it were documented more clearly. > > One last thought for Jason -- check out the Data::Locations module. Even if > you don't use it for HTML, it's great food for thought. > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From Showell30 at aol.com Tue Oct 24 14:38:43 2000 From: Showell30 at aol.com (Showell30@aol.com) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: Perl and HTML Message-ID: <68.87a4ec7.27273f43@aol.com> In a message dated Tue, 24 Oct 2000 3:24:18 PM Eastern Daylight Time, "Tim Holt" writes: << At least for me, it all depends on if you want to see what you're doing as HTML with code in it, or code with HTML in it. >> Yep, that's a good way to think of it. For me, the bigger problem is automating web page generation (a coding problem), and the problem within the problem is making the pages look nice (HTML). So, I see it as code with HTML in it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tnight at pobox.com Tue Oct 24 15:01:22 2000 From: tnight at pobox.com (Terry Nightingale) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: Re: Perl and HTML In-Reply-To: <68.87a4ec7.27273f43@aol.com> Message-ID: On Tue, 24 Oct 2000, Showell30@aol.com wrote: > Yep, that's a good way to think of it. For me, the bigger problem is > automating web page generation (a coding problem), and the problem within the > problem is making the pages look nice (HTML). So, I see it as code with HTML > in it. For me personally, the yet bigger problem is that as soon as you mix any HTML into your code, or mix any code into your HTML, you've made it difficult for a page designer to access in the former case, or easy for a page designer to change inadvertently (read: break) in the latter case. In my opinion, this problem is why the CGI/HTML nut has yet to be cracked. This of course assumes that the person who makes the pages look nice and the person who writes the page generation code are different people, which in my experience, is true of all projects with any amount of size and/or complexity. FWIW... -- Terry Nightingale +1-425-649-9304(v) / +1-425-643-7112(f) Prediction is very difficult, especially of the future. -Niels Bohr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Tue Oct 24 18:49:17 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:41 2004 Subject: SPUG: No ESPUG Meeting Tomorrow Message-ID: <20001024164917.A26206@xenon.cobaltgroup.com> There won't be an ESPUG meeting tomorrow. The next meeting will be in November. I'll post details a week or so before the actual meeting. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tim at consultix-inc.com Wed Oct 25 14:01:27 2000 From: tim at consultix-inc.com (Tim Maher/CONSULTIX) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Damian Conway Fund: Almost there! Message-ID: <20001025190127.A14092@timji.consultix.wa.com> SPUGsters, If you want Perl to be as cool as it possibly can be, then help in the effort described below to raise money to fund Damian's perl-istic activities for next year. -Tim ----- Forwarded message from Kevin Lenzo ----- Date: Wed, 25 Oct 2000 14:27:33 -0400 From: Kevin Lenzo Reply-To: lenzo@cs.cmu.edu Organization: School of Computer Science, Carnegie Mellon University X-Mailer: Mozilla 4.74 [en] (X11; U; Linux 2.2.14 i686) X-Accept-Language: en To: groups@lists.panix.com Subject: Damian Conway Fund Precedence: bulk Hello, All -- Please pardon the email; if you haven't heard, we're trying to raise enough money (US$55K) to buy out Damian Conway's responsibilities at Monash so he can work on Just Perl for a year. He has several projects in mind, and would also be wandering to give talks at Perl mongers groups throughout the world. We still need some $10K; if you can, and would like to contribute, or to find out more information on the Damian Conway in 2001 fund, please see http://yetanother.org/damian/ This is being done through the Yet Another Society, host of YAPC, and sister organization to the Perl Mongers. Thank you, kevin lenzo@cs.cmu.edu ========================================================== | Tim Maher, Ph.D. Tel: (206) 781-UNIX | | SPUG Founder & Leader Email: spug@halcyon.com | | Seattle Perl Users Group HTTP: www.halcyon.com/spug | ========================================================== - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From brian.altman at attws.com Wed Oct 25 15:36:43 2000 From: brian.altman at attws.com (Altman, Brian) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: CGI.pm popup_menu()? Message-ID: <61A811DC8715D411BF0100508B94DB1C02427693@WA-MSG11> I have some experience with Perl programming but little with the CGI.pm module. What I am trying to do is create a dynamic HTML form. What I mean by dynamic is that I want a select form item to be created using option's from a .csv file. I can read the file into an array, but I haven't figured out how to store each array item into the value list of the popup_menu() function. Can anyone help me on this? My code so far looks like: @Location; open(LOCATION,"< Location.csv") or die "Couldn't read Location.csv: $!\n"; while() { chomp; push (@Location, $_); } print popup_menu(-name=>'Location',-values=>@Location); #But this only returns the first item in the array. Thnx, Brian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From wildwood_players at yahoo.com Wed Oct 25 16:02:22 2000 From: wildwood_players at yahoo.com (Richard Wood) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: CGI.pm popup_menu()? Message-ID: <20001025210222.6936.qmail@web115.yahoomail.com> Brian, I use CGI.pm quit a bit. I believe all that you need to do is escape the array: \@Location: popup_menu(-name=>'Location',-values=>\@Location); Regards, Rich Wood --- "Altman, Brian" wrote: > I have some experience with Perl programming but > little with the > CGI.pm module. What I am trying to do is create a > dynamic HTML form. What I > mean by dynamic is that I want a select form item to > be created using > option's from a .csv file. I can read the file into > an array, but I haven't > figured out how to store each array item into the > value list of the > popup_menu() function. Can anyone help me on this? > My code so far looks > like: > > @Location; > open(LOCATION,"< Location.csv") or die "Couldn't > read Location.csv: > $!\n"; > while() { > chomp; > push (@Location, $_); > } > > print > popup_menu(-name=>'Location',-values=>@Location); > #But this only > returns the first item in the array. > > > Thnx, > Brian > > - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: > owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: > ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL > by your Email-address > For daily traffic, use spug-list for LIST ; for > weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: > http://www.halcyon.com/spug/ > > ===== Richard O. Wood Wildwood IT Consultants, Inc. wildwood_players@yahoo.com 206.605.2539 http://resumes.dice.com/richardowood __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From wildwood_players at yahoo.com Wed Oct 25 16:21:58 2000 From: wildwood_players at yahoo.com (Richard Wood) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: A refreshing look at a file system Message-ID: <20001025212159.27167.qmail@web116.yahoomail.com> SPUGsters, I have three directories for holding scripts (these scripts are used in telnet sessions with telco switches). The directories are: pending, queued, and complete. I currently have a web based interface which resembles a three tab folder with headings: PENDING, QUEUED, COMPLETE. Selecting a tab will display the scripts in that particular dir. On the Pending tab you can press a button for a script to send it to the queue to be picked up and run by a daemon. It is also possible to "VIEW" and "DELETE" scripts on this tab with appropriately named buttons. The Queue and Complete tab also have buttons. HERE IS THE QUESTION HERE IS THE QUESTION HERE IS THE QUESTION Can anyone think of a qood way to keep the interface refreshed when a change occurs to the directory being displayed, e.g. when a script is completed, it is moved to the complete directory, but how can I reflect that on the users interface where the Queue tab is currently displayed? I could use some form of META=REFRESH but that has some problems because this is a form and the refresh is pretty annoying especially when the refresh is rapid enough to be timely and when the result of the refresh is nothing happens. A friend suggested I embed a JAVA applet which would connect to the server and initiate a process to monitor the directory and signal when a change occurred. But that might run into firewall issues. I am open to some other form of interface besides web. Mostly, I would like to hear if anyone has any ideas. Regards, Rich Wood ===== Richard O. Wood Wildwood IT Consultants, Inc. wildwood_players@yahoo.com 206.605.2539 http://resumes.dice.com/richardowood __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From tuck at whistlingfish.net Wed Oct 25 17:09:51 2000 From: tuck at whistlingfish.net (Matt Tucker) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: A refreshing look at a file system In-Reply-To: <20001025212159.27167.qmail@web116.yahoomail.com> Message-ID: <35520000.972511791@benzene> -- Richard Wood spake thusly: > Can anyone think of a qood way to keep the interface > refreshed when a change occurs to the directory being > displayed, e.g. when a script is completed, it is > moved to the complete directory, but how can I reflect > that on the users interface where the Queue tab is > currently displayed? > > I could use some form of META=REFRESH but that has > some problems because this is a form and the refresh > is pretty annoying especially when the refresh is > rapid enough to be timely and when the result of the > refresh is nothing happens. A friend suggested I > embed a JAVA applet which would connect to the server > and initiate a process to monitor the directory and > signal when a change occurred. But that might run > into firewall issues. > > I am open to some other form of interface besides web. > Mostly, I would like to hear if anyone has any ideas. Another option would be to "embed" an invisible frame (as it were) that has a high enough refresh, and causes updates of the data frame when necessary. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.pm.org/archives/spug-list/attachments/20001025/4c5fd3da/attachment.bin From Showell30 at aol.com Wed Oct 25 17:20:04 2000 From: Showell30 at aol.com (Showell30@aol.com) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: A refreshing look at a file system Message-ID: Maybe some sort of two-window Javascript setup could make the META=REFRESH solution work. The controlling window would refresh often, and then, only if it got actual new data, the controlling window would refresh the main window. Haven't this thought this through too much, but I throw it out as food for thought. I worked on one project once where we had a browser-based solution to monitor live trace data, and we were able to make it work using non-parsed headers and other such things. We eventually rewrote it to be traditional client-server w/sockets, and I was glad we did it. (I used Win/MFC for client, Solaris/Perl for the middle tier). It was an internal app, though, so no firewall issues. Mainly I liked the client-server app better due to being able to add more GUI features that the users liked, but also the server code became simpler once the client got smarter (no CGI/less keeping track of state). In a message dated 10/25/00 2:58:57 PM Pacific Daylight Time, wildwood_players@yahoo.com writes: > I could use some form of META=REFRESH but that has > some problems because this is a form and the refresh > is pretty annoying especially when the refresh is > rapid enough to be timely and when the result of the > refresh is nothing happens. A friend suggested I > embed a JAVA applet which would connect to the server > and initiate a process to monitor the directory and > signal when a change occurred. But that might run > into firewall issues. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From wildwood_players at yahoo.com Wed Oct 25 18:03:33 2000 From: wildwood_players at yahoo.com (Richard Wood) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: A refreshing look at a file system Message-ID: <20001025230333.21295.qmail@web108.yahoomail.com> Thanks for the suggestions so far, I like the idea of having a hidden frame being refreshed with status and the displayed frame watching it for a change. I will pursue that for the time being. I am not certain of the firewall issues but I believe it will be a consideration. I figured someone would have an idea! Thanks Rich Wood --- Showell30@aol.com wrote: > Maybe some sort of two-window Javascript setup could > make the META=REFRESH > solution work. The controlling window would refresh > often, and then, only if > it got actual new data, the controlling window would > refresh the main window. > Haven't this thought this through too much, but I > throw it out as food for > thought. > > I worked on one project once where we had a > browser-based solution to monitor > live trace data, and we were able to make it work > using non-parsed headers > and other such things. We eventually rewrote it to > be traditional > client-server w/sockets, and I was glad we did it. > (I used Win/MFC for > client, Solaris/Perl for the middle tier). It was > an internal app, though, > so no firewall issues. Mainly I liked the > client-server app better due to > being able to add more GUI features that the users > liked, but also the server > code became simpler once the client got smarter (no > CGI/less keeping track of > state). > > In a message dated 10/25/00 2:58:57 PM Pacific > Daylight Time, > wildwood_players@yahoo.com writes: > > > I could use some form of META=REFRESH but that has > > some problems because this is a form and the > refresh > > is pretty annoying especially when the refresh is > > rapid enough to be timely and when the result of > the > > refresh is nothing happens. A friend suggested I > > embed a JAVA applet which would connect to the > server > > and initiate a process to monitor the directory > and > > signal when a change occurred. But that might > run > > into firewall issues. > > - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: > owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: > ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL > by your Email-address > For daily traffic, use spug-list for LIST ; for > weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: > http://www.halcyon.com/spug/ > > ===== Richard O. Wood Wildwood IT Consultants, Inc. wildwood_players@yahoo.com 206.605.2539 http://resumes.dice.com/richardowood __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Wed Oct 25 20:36:03 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Packaging Applications Using CPAN Modules Message-ID: <20001025183603.A7267@xenon.cobaltgroup.com> Here is the problem. I am writing an application in Perl which uses several CPAN modules. I want the application to be easy to install on different machines. I don't want to force people to first download and install the modules from CPAN that my application requires. How can I do this? So essentially I want to ship a application.tar.gz file. The end-user uncompresses/untars it and then runs "make" and then "make install" and at that point the application should be fully usable. The build/install should work even if the machine is NOT on-line and if the user has no root privileges. The required CPAN module files will be shipped with the application.tar.gz. The make and make install steps need to somehow do the following things: (1) Figure out if the correct versions of the required CPAN modules are already installed on the machine. (2) If they are not then unzip and build and install the versions shipped in the tarball. If the user is not root then the installation of these packages should be to the directory where the application is going to live. (3) Finally to build and install the application. My question is this: Is there a module on CPAN that already does this? CPAN.pm does not appear to fit the bill. The initial configuration dialog it engages the user in totally violates the idea of automated installation. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Wed Oct 25 21:20:13 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl Message-ID: <20001025192013.A7786@xenon.cobaltgroup.com> Gisle Aas mentioned this as a footnote at the last Damianathon: the main weakness in Python -- lack of modules (for example there is no general DBI module) has been fixed through his pyperl module which allows Python programs to access Perl modules. Here is the URL for pyperl module: http://www.zope.org/Wikis/zope-perl/FAQ. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From scott at sabmail.rresearch.com Wed Oct 25 22:04:16 2000 From: scott at sabmail.rresearch.com (Scott Blachowicz) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Packaging Applications Using CPAN Modules In-Reply-To: <20001025183603.A7267@xenon.cobaltgroup.com> References: <20001025183603.A7267@xenon.cobaltgroup.com> Message-ID: <20001025200416.B96174@sabami.seaslug.org> On Wed, Oct 25, 2000 at 06:36:03PM -0700, Asim Jalis wrote: > The make and make install steps need to somehow do the following > things: > > (1) Figure out if the correct versions of the required CPAN modules > are already installed on the machine. > (2) If they are not then unzip and build and install the versions > shipped in the tarball. If the user is not root then the installation > of these packages should be to the directory where the application > is going to live. > (3) Finally to build and install the application. > > My question is this: Is there a module on CPAN that already does this? Well...you COULD probably just set it up to always use YOUR version of the modules by messing around with @INC in BEGIN blocks in your application scripts? Then, you don't have to worry about your points 1 & 2. Not the most elegant solution, but it might simplify things. -- Scott Blachowicz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From bentson at grieg.holmsjoen.com Wed Oct 25 22:07:10 2000 From: bentson at grieg.holmsjoen.com (Randolph Bentson) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl In-Reply-To: <20001025192013.A7786@xenon.cobaltgroup.com>; from Asim Jalis on Wed, Oct 25, 2000 at 07:20:13PM -0700 References: <20001025192013.A7786@xenon.cobaltgroup.com> Message-ID: <20001025200710.A21656@grieg.holmsjoen.com> On Wed, Oct 25, 2000 at 07:20:13PM -0700, Asim Jalis wrote: > Gisle Aas mentioned this as a footnote at the last Damianathon: the main > weakness in Python -- lack of modules Hmm, this would be interesting, if true. Perhaps this poor soul meant "not the modules I want", which is an entirely different matter. > (for example there is no general DBI module) Other than, for instance, "anydbm" for non-SQL and mxODBC for many SQL database servers? (The anydbm module provides a generic interface that's used to open a database without specifying the lower level database package. If the database exists and the appropriate package is installed, the open succeeds. If the database doesn't exist, it is created using the first package found (according to an ordered list). The mxODBC package provides a nearly 100% Python DB API compliant interface to databases that are accessible via the ODBC API. Many databases include ODBC libraries, so this may be the only module you need; it supports Solid, Adabas, Sybase, Oracle, and even MySQL.) -- Randolph Bentson bentson@holmsjoen.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From starfire at zipcon.net Thu Oct 26 00:06:25 2000 From: starfire at zipcon.net (Richard Anderson) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl References: <20001025192013.A7786@xenon.cobaltgroup.com> <20001025200710.A21656@grieg.holmsjoen.com> Message-ID: <00c101c03f0a$8139de10$720ff93f@adcom133> Randy, without close inspection I am confident that Perl DBI is much more powerful than Python's anydbm/msODBC. DBI is actually a collection of over 100 modules, some of which were first released in the mid 90s and have undergone many upgrades. (See http://search.cpan.org/search?mode=module&query=DBI ) For example, DBI allows programmers to write code that accesses a database as a privileged user without actually exposing the password to the programmer. Can anydbm do that? I don't see Python's lack of an extensive module library as a weakness. (If this were true, it's a weakness that Python shares with Java, C++, etc.) Rather, Perl's huge library of thousands of CPAN modules is a powerful tool that has no precedent among computer languages. Richard.Anderson@rayCosoft.com RayCosoft, Professional Services Group Perl/SQL/Unix software engineering www.rayCosoft.com www.zipcon.net/~starfire/home Seattle, WA, USA ----- Original Message ----- From: "Randolph Bentson" To: ; Sent: Wednesday, October 25, 2000 8:07 PM Subject: Re: SPUG: Python/Perl > On Wed, Oct 25, 2000 at 07:20:13PM -0700, Asim Jalis wrote: > > Gisle Aas mentioned this as a footnote at the last Damianathon: the main > > weakness in Python -- lack of modules > > Hmm, this would be interesting, if true. Perhaps this poor soul meant > "not the modules I want", which is an entirely different matter. > > > (for example there is no general DBI module) > > Other than, for instance, "anydbm" for non-SQL and mxODBC for many > SQL database servers? > > (The anydbm module provides a generic interface that's used to open > a database without specifying the lower level database package. If > the database exists and the appropriate package is installed, the > open succeeds. If the database doesn't exist, it is created using > the first package found (according to an ordered list). > > The mxODBC package provides a nearly 100% Python DB API compliant > interface to databases that are accessible via the ODBC API. Many > databases include ODBC libraries, so this may be the only module you > need; it supports Solid, Adabas, Sybase, Oracle, and even MySQL.) > > -- > Randolph Bentson > bentson@holmsjoen.com > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From bentson at grieg.holmsjoen.com Thu Oct 26 00:28:19 2000 From: bentson at grieg.holmsjoen.com (Randolph Bentson) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl In-Reply-To: <00c101c03f0a$8139de10$720ff93f@adcom133>; from Richard Anderson on Wed, Oct 25, 2000 at 10:06:25PM -0700 References: <20001025192013.A7786@xenon.cobaltgroup.com> <20001025200710.A21656@grieg.holmsjoen.com> <00c101c03f0a$8139de10$720ff93f@adcom133> Message-ID: <20001025222819.A21904@grieg.holmsjoen.com> > > On Wed, Oct 25, 2000 at 07:20:13PM -0700, Asim Jalis wrote: > > > Gisle Aas mentioned this as a footnote at the last Damianathon: the main > > > weakness in Python -- lack of modules > From: "Randolph Bentson" > > Hmm, this would be interesting, if true. Perhaps this poor soul meant > > "not the modules I want", which is an entirely different matter. On Wed, Oct 25, 2000 at 10:06:25PM -0700, Richard Anderson wrote: > Randy, without close inspection I am confident that Perl DBI is much more > powerful than Python's anydbm/msODBC. I would not be surprised, given the large community which has helped with the evolution of Perl. (Given my modest exposure I've had to SQL, I'm sure there are nicer interfaces -- and DBI may be one of them. But if access to an SQL server is all you need, Python's got it already.) I was only pointing out the hyperbole in Gisle Aas's claim as reported by Asim Jalis. If the claim had been merely "Python lacks the modules I want and here's how I can get at them", I'd have had no cause to comment. -- Randolph Bentson bentson@holmsjoen.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Thu Oct 26 01:39:18 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl In-Reply-To: <20001025200710.A21656@grieg.holmsjoen.com>; from Randolph Bentson on Wed, Oct 25, 2000 at 08:07:10PM -0700 References: <20001025192013.A7786@xenon.cobaltgroup.com> <20001025200710.A21656@grieg.holmsjoen.com> Message-ID: <20001025233918.A9518@xenon.cobaltgroup.com> On Wed, Oct 25, 2000 at 08:07:10PM -0700, Randolph Bentson wrote: > On Wed, Oct 25, 2000 at 07:20:13PM -0700, Asim Jalis wrote: > > Gisle Aas mentioned this as a footnote at the last Damianathon: the main > > weakness in Python -- lack of modules > > Hmm, this would be interesting, if true. Perhaps this poor soul meant > "not the modules I want", which is an entirely different matter. > > > (for example there is no general DBI module) > > Other than, for instance, "anydbm" for non-SQL and mxODBC for many > SQL database servers? > > (The anydbm module provides a generic interface that's used to open > a database without specifying the lower level database package. If > the database exists and the appropriate package is installed, the > open succeeds. If the database doesn't exist, it is created using > the first package found (according to an ordered list). > > The mxODBC package provides a nearly 100% Python DB API compliant > interface to databases that are accessible via the ODBC API. Many > databases include ODBC libraries, so this may be the only module you > need; it supports Solid, Adabas, Sybase, Oracle, and even MySQL.) Actually that was my mistake. I didn't know about Python's extensive database modules. Gisle Aas only mentioned that he had written pyperl. The rest of the message, including the statement about Python's lack modules was mine. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From ajalis at cobaltgroup.com Thu Oct 26 01:46:10 2000 From: ajalis at cobaltgroup.com (Asim Jalis) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl In-Reply-To: <20001025222819.A21904@grieg.holmsjoen.com>; from Randolph Bentson on Wed, Oct 25, 2000 at 10:28:19PM -0700 References: <20001025192013.A7786@xenon.cobaltgroup.com> <20001025200710.A21656@grieg.holmsjoen.com> <00c101c03f0a$8139de10$720ff93f@adcom133> <20001025222819.A21904@grieg.holmsjoen.com> Message-ID: <20001025234610.B9518@xenon.cobaltgroup.com> On Wed, Oct 25, 2000 at 10:28:19PM -0700, Randolph Bentson wrote: > I was only pointing out the hyperbole in Gisle Aas's claim as reported > by Asim Jalis. If the claim had been merely "Python lacks the modules > I want and here's how I can get at them", I'd have had no cause to comment. Ack. That was my claim. I hope the misattribution has been cleared. I should have phrased the post more carefully. Gisle Aas merely mentioned that he had written pyperl. Taht was the extent of his claim. The rest of the message was mine. Asim - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mcglk at serv.net Thu Oct 26 05:59:39 2000 From: mcglk at serv.net (Ken McGlothlen) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Re: Perl and HTML In-Reply-To: Message-ID: I've been thinking about this a lot over the last year. I continually find myself frustrated with webpage generation, and I wish there was a good way to meld what is a loose collection of partial solutions together. First of all, using HTML as a source language is a dead-end route. That would be fine if all the browsers out there supported XML, but they don't; instead, people are using browsers that support bits and subsets of HTML, often in different ways. Shifting to XML as a source language makes it easier to support future browsers, most of which will (hopefully) be adhering fairly closely to the standards. Second, server-side manipulation isn't a great answer in all cases, either. The majority of content on the Web is static in nature, and speed is of the essence for most websites. In addition, many small sites can't really afford a lot of custom services by their ISPs in order to support server-side processing (AxKit, etc.). Finally, XML isn't a great tool for certain things. Character entities are a pain; there should be a way to perform text substitutions conveniently (which would also be useful for other things). And sometimes, there needs to be some programmatic control that XML/XSLT doesn't cover (like "current time"). It's great for static replacements, but doesn't provide all that much control over non-tag content. The sad thing is that this sort of thing was covered a long time ago by various text-processing systems. Take TeX, for example: flexible, precise, and a full macro language to boot. So why isn't there a true XML macro language by now? One that could be plugged into Apache, for example, if you needed on-the-fly conversion (ecommerce, games, etc.), but one that can be run independently as a compiler for those that run small static websites? Now, pardon me if there are any errors in here---I'm writing this off the top of my head, and it is nearly 4am as I write this---but wouldn't it be nice if we could write Not-so-frequently asked questions Would you say, ``Is it farther to Spokane or by bus~24?'' No---in general, the sun has no half-tildes \<1/2 \~s\>. with the following DTD for syntax checking: and the following .xsl file for processing: use POSIX; my( $filename ) = shift; return( strftime( "%Y/%M/%D", localtime( (stat( $filename ))[9] ) ) ); <xsl:value-of select = "title"/>


Last modified:

Q:

A:

 
and be able to type a simple command and get the resulting HTML? This sort of approach might just make Perl the preferred language for XML processing, since it'd be fully macroizable, and also make it not too far off the standards for XML/XSLT. I dunno; maybe it's not such a good idea, but I yearn for this sort of flexibility. For example, I'd love to have something like small caps, which translates the following (assuming the default font size here): Seattle Perl Users Group to SEATTLE PERL USERS GROUP Or even more complex macros. I'd love to see SPUG involved in something like this. Between XML::Parser, subroutine references, eval, and XML::XSLT, this really shouldn't be all that hard, should it? And I suspect that a tool like this would get used. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From briani at activestate.com Thu Oct 26 15:10:16 2000 From: briani at activestate.com (Brian Ingerson) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Python/Perl References: <20001025192013.A7786@xenon.cobaltgroup.com> Message-ID: <39F88FA8.DF27A9F2@activestate.com> Asim Jalis wrote: > > Gisle Aas mentioned this as a footnote at the last Damianathon: the main > weakness in Python -- lack of modules (for example there is no general > DBI module) has been fixed through his pyperl module which allows Python > programs to access Perl modules. Here is the URL for pyperl module: > http://www.zope.org/Wikis/zope-perl/FAQ. As a point of interest, one of my coworkers at @$ (my ackronym for ActiveState) has successfully added Python support to Inline.pm! You can call Python functions like Perl subs and pass scalars/arrays/hashes back and forth. It will be available in version 0.30 (the next major release) due out by Chistmas ;) There are many other cool changes as well. I'll post a prerelease to SPUG as soon as the whole thing is stable again. Brian -- perl -e 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf ("Just Another %s Hacker\\n",x);}};print JAxH+Perl' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From jason at strangelight.com Thu Oct 26 03:36:48 2000 From: jason at strangelight.com (Jason Lamport) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: CGI.pm popup_menu()? In-Reply-To: <20001025210222.6936.qmail@web115.yahoomail.com> References: <20001025210222.6936.qmail@web115.yahoomail.com> Message-ID: At 2:02 PM -0700 10/25/00, Richard Wood wrote: >Brian, > >I use CGI.pm quit a bit. I believe all that you need >to do is escape the array: > >\@Location: > >popup_menu(-name=>'Location',-values=>\@Location); Technical nit-pick: You aren't "escaping" the array, you're taking a reference to it. There's a *big* difference. (The difference between, e.g. print "\@Location"; and print \@Location; ) -jason - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From meonkeys at hotmail.com Thu Oct 26 15:21:05 2000 From: meonkeys at hotmail.com (Adam Monsen) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: ePerl templating Message-ID: Any Apache::ePerl users out there? I've had great success with this module: I especially like the ease of installation/use and error reporting. I don't understand an easy way to do templating; for example, using a common header or footer. I don't want to use SSI (unless this can't be done with ePerl). This is what I would like to do: include('path/to/template', param1 => 'A', param2 => 'B'); !> but even include('path/to/template') !> would be pretty cool too. Does this make sense? On a side note, www.template-toolkit.org looks very interesting. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From slagel at geospiza.com Fri Oct 27 13:23:13 2000 From: slagel at geospiza.com (Joe Slagel) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Re: Perl and HTML References: Message-ID: <39F9C811.83E83EEF@geospiza.com> Ken McGlothlen wrote: > I've been thinking about this a lot over the last year. I continually find > myself frustrated with webpage generation, and I wish there was a good way to > meld what is a loose collection of partial solutions together. Lots of XSLT stuff omitted.... I'd like to be able to do exactly what you've specified, but not with bloody XSL. I like perl...I like it's regrex...I like it's speed and simplicity. It should be possible to format XML into whatever you want in perl instead of using XSL using some nifity and handy perl modules. These modules could be layed out in an OO fashion allowing one to use inheritance and overriding methods to change the formatting. With a good inital architecture, you probably could see alot of modules for formatting XML down the road... -- Joe Slagel Geospiza, Inc. 3939 Leary Way NW, Seattle WA 98107 (206) 633-4403 slagel@geospiza.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From aaron at activox.com Fri Oct 27 14:56:40 2000 From: aaron at activox.com (Aaron Salo) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Re: Perl and HTML In-Reply-To: <39F9C811.83E83EEF@geospiza.com> References: Message-ID: <3.0.5.32.20001027125640.00a67c40@127.0.0.1> At 11:23 AM 10/27/00 -0700, you wrote: >I'd like to be able to do exactly what you've specified, but not with bloody XSL. my $full_agreement = ($_ * 100); >It should be >possible to format XML into whatever you want in perl instead of using XSL using >some nifity and handy perl modules. These modules could be layed out in an >OO fashion allowing one to use inheritance and overriding methods to change the >formatting. This is entirely compatible with the spirit of XML, makes complete sense. >With a good inital architecture, you probably could see alot of >modules for formatting XML down the road... Well said. There is certainly room on CPAN for a comprehensive module of the scope of CGI.pm to handle this kind of stuff. Maybe Lincoln Stein has some free time on his hands...XSLT sucks IMHO, yes, before anyone rushes to the defense I know it's an immature spec and everyone has to start somewhere. I am also still gunshy from my Bad Experience as an wannabe early adopter back when Java was going to save the world and between 1.0 and 1.1 half of the spec got deprecated. I don't want to invest any time doing rework in the aftermath of DOM vs. SAX vs. [foo]. In the interim, for file driven stuff like content management applications and the like I am writing data files as valid XML and writing middleware scripts in Perl to parse them to a template and get what I want to STDOUT. Ugly (very) but effective. In my mind this is a good investment because those datafiles should migrate to [whatever] when something sane is available. I see big value in XML and having the data be independent from the presentation. I have tried very hard to like it. But the hoops you have to jump thru and the very limited functionality in XSLT has made me abandon it every time. Have messed with Cocoon but they still have a long way to go - and I would REALLY prefer NOT to use JServ/Tomcat/[insert java servlet handler of the month here] in favor of a natural 100% Perl solution. Anyone have any better luck with this than I have? Or is this just crazy talkin? ~!a ___a_c_t_i_V_o_x________________________________________ Aaron Salo actiVox new media http://www.activox.com internet leverage, new media development, and whatever acronym you need implemented +1.360.434.8547 -- aaron(at)activox.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From acme at astray.com Fri Oct 27 19:15:16 2000 From: acme at astray.com (Leon Brocard) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Re: Perl and HTML In-Reply-To: <3.0.5.32.20001027125640.00a67c40@127.0.0.1>; from aaron@activox.com on Fri, Oct 27, 2000 at 12:56:40PM -0700 References: <39F9C811.83E83EEF@geospiza.com> <3.0.5.32.20001027125640.00a67c40@127.0.0.1> Message-ID: <20001028011516.A10873@ns0.astray.com> Aaron Salo sent the following bits through the ether: > Have messed with Cocoon but they still have a long way to go - > and I would REALLY prefer NOT to use JServ/Tomcat/[insert java servlet > handler of the month here] in favor of a natural 100% Perl solution. You'll probably like AxKit, Matt Sergeant's XML application server. You can use XSLT if you really want, or XPathScript instead... http://www.axkit.org/ HTH, Leon -- Leon Brocard.............................http://www.astray.com/ yapc::Europe............................http://yapc.org/Europe/ ... Where has all that spare time just come from? ;-) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mcglk at serv.net Fri Oct 27 21:10:12 2000 From: mcglk at serv.net (Ken McGlothlen) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Re: Perl and HTML In-Reply-To: <39F9C811.83E83EEF@geospiza.com> Message-ID: | I'd like to be able to do exactly what you've specified, but not with | bloody XSL. I like perl...I like it's regrex...I like it's speed and | simplicity. It should be possible to format XML into whatever you want in | perl instead of using XSL using some nifity and handy perl modules. Well, I'd be fine with that, as long as I could declare it all in the XML documents, and have a convenient "makemake" command. Something like Engelschall's WML http://www.engelschall.com/sw/wml/ for XML would be fine, though WML seems very Tinkertoyed together and is pretty much inextricable from HTML at this point. Syntax checking would have to be part of this (using XML DTDs), though; that's kind of hard to avoid for compatibility's sake. It'd be nice if the HTML output could be checked for browser compatibility (warnings if using table-cell backgrounds for pre-3.0 browsers, for example) depending on command switches, for example. . . . Y'know, I wouldn't even mind contributing funds to this sort of project, if some SPUGger wanted to do it, and there were enough people interested and willing to pitch in. . . . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From aaron at activox.com Fri Oct 27 22:17:03 2000 From: aaron at activox.com (Aaron Salo) Date: Wed Aug 4 00:07:42 2004 Subject: SPUG: Re: Perl and HTML In-Reply-To: <20001028011516.A10873@ns0.astray.com> References: <3.0.5.32.20001027125640.00a67c40@127.0.0.1> <39F9C811.83E83EEF@geospiza.com> <3.0.5.32.20001027125640.00a67c40@127.0.0.1> Message-ID: <3.0.5.32.20001027201703.00ea7850@127.0.0.1> At 01:15 AM 10/28/00 +0100, Leon Brocard wrote: >You'll probably like AxKit, Matt Sergeant's XML application >server. You can use XSLT if you really want, or >XPathScript instead... http://www.axkit.org/ I'd forgotten about that, I looked at it quite a while ago, it looks like it's progressed quite nicely in the interim. Thank you very much for bringing it up!! ___a_c_t_i_V_o_x________________________________________ Aaron Salo actiVox new media http://www.activox.com internet leverage, new media development, and whatever acronym you need implemented +1.360.434.8547 -- aaron(at)activox.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/ From mark.mertel at home.com Thu Oct 5 15:23:19 2000 From: mark.mertel at home.com (Mark Mertel) Date: Wed Aug 4 00:08:13 2004 Subject: SPUG: tonights talk Message-ID: <00100513362700.04067@brainiac> SPUGers, are there plans for some kind of get together this evening ? I couldn't quite fathom the consensus - most seemed still floating in some kind of Damien cloud - and Tims got nothing on tap - nor should he considering he's been carrying the water most of the time. I know there's been a lot of talk about getting a hiring manager in (not sure about that title), so un- or under-employed SPUGers could stay clothed and fed. I'm not a hiring manaber per se, just a fairly successfuly independent consultant who might be looking to change careers - used to be a musician and thinking I want it back. The stuff I work on is for a single client - fortune 500 - keeps me busy, way to busy to do anything else. Written mostly in PERL, uses Sybase, MQ Series and other little things. I am currently interested in finding someone to take some of the load so that I can take a couple of steps back and see where I'm going. This would have to someone I could trust, basically, with my life and livelihood, as it is a long rode to a for-profit musical career. I would be willing to talk to anyone in the group about this if there is interest. -- Mark Mertel mark.mertel@home.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/ From mark.mertel at home.com Thu Oct 12 06:29:48 2000 From: mark.mertel at home.com (Mark Mertel) Date: Wed Aug 4 00:08:14 2004 Subject: SPUG: Social Perl Meetings In-Reply-To: References: Message-ID: <00101204324200.00814@brainiac> hey, nobody likes to clean up after a party, right ? there's a little place on first hill called vito's where there's good food - so i'm told - plentiful alcohol, lots of room, and on monday's you can hear some pretty good jazz, and the barkeep, nina, will clean up the desecration you leave behind. and best of all, the cowboy, will be there. On Mon, 27 Aug 2001, you wrote: > Heya all, > > My roommates just returned from their honeymoon, and I discussed this > with them. It looks like it'll take 5 weeks to brew a batch, and they > said they think we can provide catoring to a group of 15 or so. I'm > going to order the beer makin' stuff tomorrow, then I'll let y'all > know when we everything's ready. > > Since it's going to be over a month before we're ready here, does > anyone else have some space they can offer for a get-together for this > week? > > As this whole thing is a little off-topic from normal Spug traffic, > should we set up a mailing list for this kind of discussion? It's > pretty common for the local .pm group to be more of a social > get-together thing, so my suggestion would be to bring the Seattle.pm > list to life. What's everybody think? > > C.J. > > On Thu, 23 Aug 2001, C.J. Collier wrote: > > > > > > > On Wed, 22 Aug 2001, Alyssa Harding wrote: > > > > > Sorry I couldn't be at the meeting last night - sounds like it was a lot > > > of fun. Maybe we should consider having a 'social' meeting at more > > > regular intervals (like every six months or so?). > > > > We were also discussing 'social' meetings and most of us at the > > meeting agreed that they should happen at more regular intervals, but > > much more frequently than every six months; more like every six (or > > seven :) days. > > > > I volunteered my house and facilities (of which include home-brew > > kegs, a bar-b-q and plenty of extra hub space) for one of these > > git-togethers. We've probably got room for 10 - 15 people. If > > anyone's interested, please RSVP so I can fill the kegs, clean the > > house prepare the place for socializing and perl talk. > > > > C.J. > > > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > > Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/ > > > > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org > Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL > Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address > For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest > Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/ -- Mark Mertel mark.mertel@home.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/ From mark.mertel at home.com Fri Oct 20 11:03:43 2000 From: mark.mertel at home.com (Mark Mertel) Date: Wed Aug 4 00:08:18 2004 Subject: SPUG: Re: Re: SPUG 9/18, room, AV, and Andy In-Reply-To: <3BA211C8.7010506@scherrer.com> References: <002301c13c91$b7f84470$2788ddd1@aciwin> <3BA211C8.7010506@scherrer.com> Message-ID: <00102009051000.00811@brainiac> On Fri, 14 Sep 2001, Jay Scherrer wrote: > Earlier, I had sent a notice to Spug: Phinney Neighborhood Center > opening up a new technology center. Maybe they will allow Spug to be > held there some times? Plenty of parking, Large rooms. > Jay > this get my vote - much more convenient -- Mark Mertel mark.mertel@home.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST TO: spug-list@pm.org PROBLEMS: owner-spug-list@pm.org Subscriptions; Email to majordomo@pm.org: ACTION LIST EMAIL Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/