From vannwms at mindspring.com Fri Aug 25 22:31:39 2000 From: vannwms at mindspring.com (Valerie Vann-Williams) Date: Thu Aug 5 00:08:04 2004 Subject: [HRPM] "My class" program Message-ID: I finished correcting my first perl program we reviewed in class today. I have another problem... the program only works with whole numbers. Can you give me a hint? How should I proceed? I'm going to start on the same program using hashes now. Your assistance is greatly appreciated. Valerie -------------- next part -------------- A non-text attachment was scrubbed... Name: Myclass Type: application/octet-stream Size: 1848 bytes Desc: not available Url : http://mail.pm.org/archives/norfolk-pm/attachments/20000825/cc1068c0/Myclass.obj From chicks at chicks.net Wed Aug 2 07:42:10 2000 From: chicks at chicks.net (chicks@chicks.net) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] Yung Park's email address Message-ID: Does anybody know Yung Park's new email address? Maybe Yung? :-) The address I had for him at ODU is bouncing. -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - - C.A.R. Hoare From jduffy at semcor.com Wed Aug 2 08:31:32 2000 From: jduffy at semcor.com (jeff) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] Yung Park's email address References: <8525692F.00466CD7.00@NTMTA2.semcor.com> Message-ID: <398822B4.837D9C1E@semcor.com> chicks@chicks.net wrote: > > Does anybody know Yung Park's new email address? Maybe Yung? :-) The > address I had for him at ODU is bouncing. I left a message on his voicemail. I'l get it when I talk to him later. Jeff From chicks at chicks.net Thu Aug 3 13:49:08 2000 From: chicks at chicks.net (chicks@chicks.net) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] Very cool looking XML module. Message-ID: http://www.cpan.org/modules/by-module/XML/RHANSON/XML-EasyOBJ-1.0.readme -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - - C.A.R. Hoare From jduffy at semcor.com Thu Aug 3 13:55:39 2000 From: jduffy at semcor.com (Jeff Duffy) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] Very cool looking XML module. References: <85256930.0066AE15.00@NTMTA.semcor.com> Message-ID: <3989C02B.3EA93BAA@semcor.com> chicks@chicks.net wrote: > > http://www.cpan.org/modules/by-module/XML/RHANSON/XML-EasyOBJ-1.0.readme > I could see a few cases where this could be useful, but I like the event-based structure of XML::Parser. This module really requires you to know the layout of the document first (Of course, if there's a DTD, you could just parse that and use it as a template for code generation). I was playing a bit with XML::Parser a couple of weeks ago, and it's very cool to be able to say "Everytime you encounter a element, do this". You could do the same thing with the above, but you would end up with like fifty nested loops (although I was just reading about the concept of buillding factory objects, which would fit in well there). Jeff -- "I can't afford to make exceptions. I mean once word leaks out that a pirate has gone soft people begin to disobey him, and its nothing but work, work, work all the time." -- The Dread Pirate Roberts From chicks at chicks.net Fri Aug 11 23:06:31 2000 From: chicks at chicks.net (chicks@chicks.net) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] Re: [twuug] Address change In-Reply-To: <3994277C.6B170D31@nfx.net> Message-ID: On Fri, 11 Aug 2000, firespring wrote: > I must have missed the first part of this thread. Not really. I don't think anything has been mentioned about it on the list. > Was someone talking about offering PERL classes somewhere? The local Hampton Roads Perl Mongers ( http://norfolk.pm.org ) put on a free perl class this Spring at Semcor. Plans for a Fall class are being considered and would have been held at Semcor again if Jeff hadn't switched jobs! Work has been going on for several months to vastly improve the content being taught. A full public announcement of that should come out in the next month or so. -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - - C.A.R. Hoare From webmaster at udtseals.com Mon Aug 21 12:37:49 2000 From: webmaster at udtseals.com (Michael Theiss) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] scaler or array and why? Message-ID: <002b01c00b96$8682e8a0$c301a8c0@alphas.com> Hello all, I'm working with a web page that includes several .shtml files that I'm using for a master template. Question: I need to put all of parsed and interpolated output of master_htm.pl page into a variable that will then be assigned to an array. Should I put master_htm.pl into a scaler or an array and can you give me an ideal how to approach that. Thanks in advance. Michael Theiss webmaster@udtseals.com To view the current output of master_htm.pl http://www.udtseals.com/cgi-bin/0/warrior_links0/templates/master_htm.pl master_htm.pl ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- --------- #!/usr/bin/perl print "Content-type: text/html\n\n"; print "\n"; print "\n"; { &PostIt; } print "\n"; print "\n"; { &PostIt0; } print "\n"; print "\n"; print "\n"; { &PostIt1; } print "\n"; print "\n"; { &PostIt2; } print "\n"; print "\n"; { &PostIt3; } print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "

 

\n"; print "
\n"; print "
[Add] [Search
\n"; print "

!INSERT!

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; { &PostIt4; } print "\n"; print "\n"; { &PostIt5; } #print "        \n"; print "\n"; print "\n"; print "\n"; sub PostIt { $postit="/home/alphaudt/www/cgi-bin/0/includes/meta_data.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } sub PostIt0 { $postit="/home/alphaudt/www/cgi-bin/0/includes/onmouseover.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } sub PostIt1 { $postit="/home/alphaudt/www/cgi-bin/0/includes/header.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } sub PostIt2 { $postit="/home/alphaudt/www/cgi-bin/0/includes/left_nav_table.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } sub PostIt3 { $postit="/home/alphaudt/www/cgi-bin/0/includes/start_middle_table.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } sub PostIt4 { $postit="/home/alphaudt/www/cgi-bin/0/includes/right_table.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } sub PostIt5 { $postit="/home/alphaudt/www/cgi-bin/0/includes/footer.shtml"; open (POST,$postit) || die "can't open $postout"; $postit=""; while (){$postit .=$_;} close(POST); print "$postit"; } 1; ---------------------------------------------------------------------------- ------------------------------------------------------------------ From jeff at alanne.com Wed Aug 23 01:47:22 2000 From: jeff at alanne.com (jeff) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] scaler or array and why? References: <002b01c00b96$8682e8a0$c301a8c0@alphas.com> Message-ID: <39A3737A.F929DC0A@alanne.com> Michael Theiss wrote: > Question: I need to put all of parsed and interpolated output of > master_htm.pl page into a variable that will then be assigned to an array. Well, I have a couple of (maybe helpful) comments: 0. Always 'use strict'. Always. Always always always.'-w' is a good idea too. 1. Anytime you find yourself writing the same code multiple times, it's a good bet that you can genericize it down to one. Why not make all of your PostIt() subs a single sub, and pass it arguments instead? Something like: From the calling code: my $filename = "/home/alphaudt/www/cgi-bin/0/includes/onmouseover.shtml"; &post_it($filename); The sub: sub post_it{ my $filename = shift; open(FILE, $filename) or die "can't open $filename: $!\n"; local $/ = undef; my $whole_file = ; close(FILE) or die "Error closing $filename: $!\n"; print $whole_file; } Better yet, stuff the names of your files into an array and use that to call the sub: my @files = qw( /home/alphaudt/www/cgi-bin/0/includes/onmouseover.shtml /home/alphaudt/www/cgi-bin/0/includes/meta_data.shtml you_get_the_idea ); Then just: &post_it( $files[0] ); &post_it( $files[1] ); This lets you change everything in one neat place, if you need to. # Neat recursive explanation 2. A neat trick to slurp in the contents of a file is to make a local copy of the $/ variable (the input record separator, normally a newline). Instead of: while (){$postit .=$_;} you do: local $/ = undef; my $whole_file = ; #slurp it all into one scalar 3. Use here documents for printing multiple lines. Instead of: print "Content-type: text/html\n\n"; print "\n"; print "\n"; do this: print < END 4. The thing about saving it to a scalar is that your output is going to STDOUT, not your script. You can get around this by wrapping the whole thing in an eval{} block, like so: my $output = eval{ print < END ... &post_it( $files[0] ); ... &post_it( $files[1] ); ... }; I'm not sure what good this does you, since you end up with the entire output in a scalar, but nowhere for it to go. Also keep in mind that this approach can consume copious amounts of memory, since you're stuffing everything into a variable. Reference the Camel book for more. Hope this helps. Jeff From chicks at chicks.net Wed Aug 23 12:31:27 2000 From: chicks at chicks.net (chicks@chicks.net) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] scaler or array and why? In-Reply-To: <39A3737A.F929DC0A@alanne.com> Message-ID: On Wed, 23 Aug 2000, jeff wrote: > Michael Theiss wrote: > > Question: I need to put all of parsed and interpolated output of > > master_htm.pl page into a variable that will then be assigned to an array. > > Well, I have a couple of (maybe helpful) comments: I'm going to make a couple of nits about your helpful comments. ;-) [ For the uninitiated, Jeff and I maintain some friendly harassment about our different styles of getting things accomplished in perl. TIMTOWTDI. ] > 0. Always 'use strict'. Always. Always always always.'-w' is a good > idea too. Always use '-w'. 'use strict' is usually a good idea. :-) If I'm writing something I'm going to throw away after one use, use strict isn't worth the trouble. For anything mod_perl, serious applications programming, anything with more than 3 functions, then always 'use strict'. Sometimes 'strict' is just too much of a pain. When i was doing lots of CGI programming and working with alternative name spaces for variables the program just wouldn't work under a total use strict. > 1. Anytime you find yourself writing the same code multiple times, > it's a good bet that you can genericize it down to one. Why not make > all of your PostIt() subs a single sub, and pass it arguments instead? > Something like: > > From the calling code: > > my $filename = > "/home/alphaudt/www/cgi-bin/0/includes/onmouseover.shtml"; > &post_it($filename); The ampersand (&) is only necessary for perl4 compatibility or creating references and it's basically ugly for just a plain call. > The sub: > > sub post_it{ > my $filename = shift; > open(FILE, $filename) or die "can't open $filename: $!\n"; > local $/ = undef; > my $whole_file = ; > close(FILE) or die "Error closing $filename: $!\n"; > print $whole_file; > } If you take the newline off the die it will give you the line number which is usually pretty helpful. > Better yet, stuff the names of your files into an array and use that > to call the sub: > > my @files = qw( /home/alphaudt/www/cgi-bin/0/includes/onmouseover.shtml > /home/alphaudt/www/cgi-bin/0/includes/meta_data.shtml > you_get_the_idea ); > > Then just: > > &post_it( $files[0] ); > &post_it( $files[1] ); foreach $file (@files) { post_it($file); } # :-) > 3. Use here documents for printing multiple lines. Instead of: > > print "Content-type: text/html\n\n"; > print "\n"; > print "\n"; > > do this: > > print < Content-type: text/html > > > > END You can also just let your data be a big quoted string: print 'Content-type: text/html '; I used single quotes in this case and I recommend doing so by default. If you need interpolation you can switch to double quotes and escape all the bad characters. -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - - C.A.R. Hoare From jeff at alanne.com Thu Aug 24 18:27:03 2000 From: jeff at alanne.com (jeff) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] scaler or array and why? References: Message-ID: <39A5AF47.70529BC0@alanne.com> chicks@chicks.net wrote: > When i was doing > lots of CGI programming and working with alternative name spaces for > variables the program just wouldn't work under a total use strict. I might agree more with this, but Perl 5.6 introduced 'our', which lets you declare a variable as global and still maintain the lexical scoping requirements of the strict pragma. I use to complain loudly about having to write things like $Foo::var in order to 'use strict', but now it's just an issue of how lazy you want to be. > The ampersand (&) is only necessary for perl4 compatibility or creating > references and it's basically ugly for just a plain call. Okay, in this case I agree. > If you take the newline off the die it will give you the line number which > is usually pretty helpful. Also cool. > > Better yet, stuff the names of your files into an array and use that > > to call the sub: > > > > my @files = qw( /home/alphaudt/www/cgi-bin/0/includes/onmouseover.shtml > > /home/alphaudt/www/cgi-bin/0/includes/meta_data.shtml > > you_get_the_idea ); > > > > Then just: > > > > &post_it( $files[0] ); > > &post_it( $files[1] ); > foreach $file (@files) { post_it($file); } # :-) Bzzzzt! He wanted to incorporate other data between the output of each sub. Here, you are running the outputs together, which doesn't do what he was looking for. > print 'Content-type: text/html > > > > '; > > I used single quotes in this case and I recommend doing so by default. If > you need interpolation you can switch to double quotes and escape all the > bad characters. This is also cool, but I was trying to give him the option of interpolating the output of the subs as scalars so the whole page could be printed at once. Using single quotes increases the number of print statements by the number of subs, which I consider ugly. Having said all that, I would probably take another approach to generating the content in any case, pulling in the HTML from somewhere else and using pure Perl to automagically glue it all together. TIMTOWTDI. Jeff From twebster at pcs.cnu.edu Fri Aug 25 09:03:30 2000 From: twebster at pcs.cnu.edu (Troy E. Webster) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] scaler or array and why? In-Reply-To: <39A5AF47.70529BC0@alanne.com> Message-ID: Hey all, I am getting random messages from this list. I seem to sometimes get answers with no questions or vice-versa. Is there some problem with the mailing list? I would really like to benefit from peoples' problems and solutions, but it seems like I don't get every message. On the hrpm web site, the mailing list is norfolk-pm-list@hfb.pm.org., but I also sometimes get messages from norfolk-pm-list@happyfunball.pm.org Which one is correct, or are both? Obviously, hfb stands for happyfunball, but which one should I submit questions to? Or does it matter? Also, isn't there supposed to be a meeting soon, like next week? Not complaining, just curious ... Troy Webster From chicks at chicks.net Fri Aug 25 12:16:19 2000 From: chicks at chicks.net (chicks@chicks.net) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] list screwiness In-Reply-To: Message-ID: On Fri, 25 Aug 2000, Troy E. Webster wrote: > I am getting random messages from this list. I seem to sometimes get > answers with no questions or vice-versa. Is there some problem with > the mailing list? I would really like to benefit from peoples' > problems and solutions, but it seems like I don't get every message. > > On the hrpm web site, the mailing list is norfolk-pm-list@hfb.pm.org., > but I also sometimes get messages from > norfolk-pm-list@happyfunball.pm.org > > Which one is correct, or are both? Obviously, hfb stands for > happyfunball, but which one should I submit questions to? Or does it > matter? I'm not sure what the story with the mailing list is. I haven't noticed that I've been missing any. Has anyone else noticed spurious list behavior? I can run the list off my own list server if necessary. > Also, isn't there supposed to be a meeting soon, like next week? Yeah. I'll send out an official announcement today. -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - - C.A.R. Hoare From mpatten at exis.net Fri Aug 25 17:02:57 2000 From: mpatten at exis.net (Mike Patten) Date: Thu Aug 5 00:08:07 2004 Subject: [HRPM] list screwiness In-Reply-To: Message-ID: On Fri, 25 Aug 2000 chicks@chicks.net wrote: > I'm not sure what the story with the mailing list is. I haven't noticed > that I've been missing any. Has anyone else noticed spurious list > behavior? I can run the list off my own list server if necessary. I haven't seen anything that would indicate a problem. (i.e. all the answers I've seen also had questions and my questions have been answered-- although it's been a while since I had a question.) I hadn't seen much activity here in the last couple of weeks until a few days ago when there was a CGI question about whether it would be better to use scalars or an array. I saw a reply from Jeff, one from Chris, and Jeff's reply to Chris. If it helps, the following lines from my .procmailrc have worked for me: :0: * ^Reply-To: norfolk-pm-list@happyfunball\.pm\.org hrpm -- Mike Patten From webmaster at udtseals.com Fri Aug 25 19:35:00 2000 From: webmaster at udtseals.com (Michael Theiss) Date: Thu Aug 5 00:08:08 2004 Subject: [HRPM] newby_Perl_copious_memory_consumer_program Message-ID: <004f01c00ef5$782d8780$0300050a@vbch1.va.home.com> #/usr/bin/perl -w use strict; ################################################################################## #********************************************************************************** #*** The original author of the proram is 'magic1on' #** Contributing mentors: Jeff, #** #** *******This program is pre beta*********** #** #********************************************************************************** ###This script is being written to fulfill the following need: ###1. To import 7 or more :text/html files and parse the imput with some local ### :text/html content and then put the resulting document into a scaler ### which will then be assigned to @master which will then be joined to one ### of 8 possible scalers listed in the sub routine below. The subroutine below ### serves as a global routine for the main.cgi script at the following url: ### http://www.udtseals.com/cgi-bin/0/warrior_links0/main.cgi ### ### ### sub LoadTemplate { ### my($file) = @_; ### open(TEMPLATE, "$file")||&DieNice("Opening: $file -- $!"); ### my @template =