From Doug.Hendricks at tnzi.com Wed Dec 4 19:29:35 2002 From: Doug.Hendricks at tnzi.com (Doug Hendricks) Date: Thu Aug 5 00:24:16 2004 Subject: Can you recommend a book for perl/cgi? Message-ID: <1D205786B72AEF47B559F32D5E9CE1FA0D11DF@wnmail1.tnzi.com> Hello, Wellington. I've been using Perl 5, both OO and non-OO, for a few years now and am fairly confident. I know *nothing* about web programming -- I use Perl as a general-purpose application language and for scripting. I may need to upskill to server-side web programming soon, maybe mostly cgi stuff (not sure yet). What modern books can you recommend? I have a comp-sci/engineering background, so dense/academic books are acceptable (but not required). I am already interested in "Writing CGI Applications with Perl" by Meltzer and Michalski. Is it good? Sincerely yours, Doug Hendricks From Grantm at web.co.nz Wed Dec 4 19:58:48 2002 From: Grantm at web.co.nz (Grant McLean) Date: Thu Aug 5 00:24:16 2004 Subject: Can you recommend a book for perl/cgi? Message-ID: <5FA042F680739D44951B00FED8BE1A7D05DC14@dasher.webdom1.web.co.nz> Hi Doug I've done the odd bit of web programming but when I started there were no books. There's a very low threshold to getting started. For example, this is a fully functional CGI program: #!/usr/local/bin/perl -w my $now = localtime(); print < Hello World

The time is now: $now

EOF Drop it in your web server's CGI-bin directory, make it executable, point your browser at it and you're away. Some tips: * Once you get on to processing forms and query strings, use CGI.pm to handle that side of things - don't try to roll your own parameter handling code. * 'use CGI::Carp qw(fatalsToBrowser);' can save you a lot of stress when your script contains errors (of course you'd save even more stress by not writing scripts with errors in the first place). * CGI.pm provides functions for generating HTML - I have not found them to be useful and people smarter than me recommend against using them. (see also next point). * Once you've gotten past the toy scripts, you'll want to separate content from logic (ie: unlike my script above, you should aim to have close to zero HTML in your code). I have used the Template Toolkit (from CPAN) and swear by it. Other people like HTML::Template. * If you're lucky enough to be using Apache, find out about mod_perl and use it. O'Reilly's "Writing Apache Modules in Perl and C" by Doug MacEachern (Mr mod_perl) and Lincoln Stein (Mr CGI.pm) is excellent. * mod_perl will open up the possibility of other templating systems including Mason, embperl and Apache::ASP. * If you're using XML, you might want to look at AxKit. * Ask questions on this list. * Visit PerlMonks (http://www.perlmonks.org) * Have fun. Cheers Grant =============================================================== Grant McLean BearingPoint Inc - formerly The Web Limited +64 4 495 9026 Level 6, 20 Customhouse Quay, Box 1195 gmclean@bearingpoint.biz Wellington, New Zealand > -----Original Message----- > From: Doug Hendricks [mailto:Doug.Hendricks@tnzi.com] > Sent: Thursday, December 05, 2002 2:30 PM > To: wellington-pm-list@pm.org > Subject: Can you recommend a book for perl/cgi? > > > > Hello, Wellington. > > I've been using Perl 5, both OO and non-OO, for a few years > now and am fairly confident. > I know *nothing* about web programming -- I use Perl as a > general-purpose application language and for scripting. > I may need to upskill to server-side web programming soon, > maybe mostly cgi stuff (not sure yet). > > What modern books can you recommend? > > I have a comp-sci/engineering background, so dense/academic > books are acceptable (but not required). > > I am already interested in "Writing CGI Applications with > Perl" by Meltzer and Michalski. Is it good? > > Sincerely yours, > Doug Hendricks > > > From Grantm at web.co.nz Thu Dec 5 16:54:50 2002 From: Grantm at web.co.nz (Grant McLean) Date: Thu Aug 5 00:24:16 2004 Subject: CGI.pm HTML functions Message-ID: <5FA042F680739D44951B00FED8BE1A7D05DF79@dasher.webdom1.web.co.nz> Despite my disparaging remarks yesterday about the general uselessness of CGI.pm's functions for generating HTML, here's a tight little script from Randall Schwarz for generating Bullsh*t Bingo cards in HTML... ========================================================= #!/usr/bin/perl use CGI qw(:all); my @array = ("Synergy", "Strategic fit", "Core competencies", "Out of the box", "Bottom line", "Revisit", "Take that off line", "24/7", "Out of the loop", "Benchmark", "Value-added", "Proactive", "Win-win", "Think out side the box", "Fast track", "Result driven", "Empower (ment)", "Knowledge base", "At the end of the day", "Touch base", "Mindset", "Client focus (ed)", "Ballpark", "Game plan", "Leverage", "Top down", "User friendly", "On time", "Within budget", "Forecast", "Optimistic"); print header, start_html; print table({ border => 2, cellspacing => 0, cellpadding => 10 }, map { Tr( map { td( { align => 'center' }, splice @array, rand scalar @array, 1 ) } 1..5 ) } 1..5 ); print end_html; ========================================================= See this thread on PerlMonks: http://perlmonks.org/index.pl?node_id=217791 Regards Grant =============================================================== Grant McLean BearingPoint Inc - formerly The Web Limited +64 4 495 9026 Level 6, 20 Customhouse Quay, Box 1195 gmclean@bearingpoint.biz Wellington, New Zealand From worik at noggon.co.nz Fri Dec 6 15:58:00 2002 From: worik at noggon.co.nz (Worik) Date: Thu Aug 5 00:24:16 2004 Subject: Can you recommend a book for perl/cgi? In-Reply-To: <1D205786B72AEF47B559F32D5E9CE1FA0D11DF@wnmail1.tnzi.com> References: <1D205786B72AEF47B559F32D5E9CE1FA0D11DF@wnmail1.tnzi.com> Message-ID: <1039211880.29499.33.camel@stolberg> On Thu, 2002-12-05 at 14:29, Doug Hendricks wrote: > > Hello, Wellington. > > I've been using Perl 5, both OO and non-OO, for a few years now and am fairly confident. > I know *nothing* about web programming -- I use Perl as a general-purpose application language and for scripting. > I may need to upskill to server-side web programming soon, maybe mostly cgi stuff (not sure yet). > > What modern books can you recommend? > > I have a comp-sci/engineering background, so dense/academic books are acceptable (but not required). > > I am already interested in "Writing CGI Applications with Perl" by Meltzer and Michalski. Is it good? I have the O'Reilly book 'CGI Programming with Perl' 2nd. ed. and I think it is very good. It is quite basic, but server side web programming, if it is any good, is very basic. I also recomend (a bit dated now) The Perl Cookbook published by O'Reily too. But you probably have that one ;-) Worik > > Sincerely yours, > Doug Hendricks > > > From enkidu at cliffp.com Sun Dec 22 00:57:48 2002 From: enkidu at cliffp.com (Enkidu) Date: Thu Aug 5 00:24:16 2004 Subject: Struggling with scopes.... Message-ID: <0rna0vkgf3r9aenpf0s05im518t386lg34@4ax.com> I'm trying to make a program into a package....... Sooo, I've renamed the .pl to .pm I've added a package line to the file. I've converted the "mainline" to a procedure. I've created a constructor for the package which creates the object hash. In the mainline procedure I've stashed the values I need in the subroutine in the hash, eg my $self = shift ; my $proximity = $self->{proximity} = "near" ; and in the "nearness" subroutine my $self = shift ; my $proximity = $self->{proximity} ; and $proximity contains "near". How the heck do I do it with a %?? How do I stash %mindex or a pointer to it in the object hash, and how do I access it in the "nearness" subroutine? I guess I could always var it....... but I should be able to do it the other way. No doubt the solution is obvious.... Cheers, Cliff -- The Nats held a Party and no one came. From ewen at naos.co.nz Sun Dec 22 01:35:25 2002 From: ewen at naos.co.nz (Ewen McNeill) Date: Thu Aug 5 00:24:16 2004 Subject: Struggling with scopes.... In-Reply-To: Message from Enkidu of "Sun, 22 Dec 2002 19:57:48 +1300." <0rna0vkgf3r9aenpf0s05im518t386lg34@4ax.com> Message-ID: <20021222073525.7822EADFCB@basilica.la.naos.co.nz> In message <0rna0vkgf3r9aenpf0s05im518t386lg34@4ax.com>, Enkidu writes: >How do I stash %mindex or a pointer to it in the object hash, and how >do I access it in the "nearness" subroutine? Assuming that your object is a hash (rather than an array), you can stick a reference to your %mindex hash into it under some suitable name, eg: $self->{'mindex'} = \%mindex; And then you can pull it back out with something like: $mindex_ref = $self->{'mindex'}; And use it as: print $mindex_ref->{'thingy'}; Or: foreach keys %{$mindex_ref} { print "Key: $_\n"; } Or use it via the self hash directly: print $self->{'mindex'}->{'thingy'}; Or whatever works for you. This is "obvious" to me, and you say you couldn't find any obvious solution to your problem, so perhaps I've misunderstood your problem; if so feel free to explain some more. Ewen From enkidu at cliffp.com Sun Dec 22 02:24:49 2002 From: enkidu at cliffp.com (Enkidu) Date: Thu Aug 5 00:24:16 2004 Subject: Struggling with scopes.... In-Reply-To: <20021222073525.7822EADFCB@basilica.la.naos.co.nz> References: of "Sun, 22 Dec 2002 19:57:48 +1300." <0rna0vkgf3r9aenpf0s05im518t386lg34@4ax.com> <20021222073525.7822EADFCB@basilica.la.naos.co.nz> Message-ID: <6dsa0vciahv8tn8o937ni3bpd4mgqgflf6@4ax.com> On Sun, 22 Dec 2002 20:35:25 +1300, you wrote: >In message <0rna0vkgf3r9aenpf0s05im518t386lg34@4ax.com>, Enkidu writes: >>How do I stash %mindex or a pointer to it in the object hash, and how >>do I access it in the "nearness" subroutine? > >Assuming that your object is a hash (rather than an array), you can >stick a reference to your %mindex hash into it under some suitable name, >eg: > >$self->{'mindex'} = \%mindex; > >And then you can pull it back out with something like: > >$mindex_ref = $self->{'mindex'}; > >And use it as: > >print $mindex_ref->{'thingy'}; > >Or: > >foreach keys %{$mindex_ref} >{ > print "Key: $_\n"; >} > >Or use it via the self hash directly: > >print $self->{'mindex'}->{'thingy'}; > >Or whatever works for you. > >This is "obvious" to me, and you say you couldn't find any obvious >solution to your problem, so perhaps I've misunderstood your problem; if >so feel free to explain some more. > Ewen, it's because I'm still learning.... I haven't got my head around the whole data type thing yet. And thanks, it now works with the help of your hints above. Cheers, Cliff -- The Nats held a Party and no one came.