_brian_d_foy | 3 Jan 2005 20:18
Picon
Favicon

perlfaq9: How do I decode a CGI form?


* How do I decode a CGI form?

   + I'm completely replacing this answer.  The previous version
   was pretty aggressive and ranted about cargo-culting.  It also
   digressed into a discussion of HTTP methods.

   + The new answer showcases CGI.pm, and gives a couple examples.
   I'd like people to use it because it's easier, not because we
   decreed it's use.

   + I also removed the reference to cgi-lib.pl.  It is 2005 now :)

Index: perlfaq9.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq9.pod,v
retrieving revision 1.18
diff -u -d -r1.18 perlfaq9.pod
--- perlfaq9.pod        3 Jan 2005 18:43:37 -0000       1.18
+++ perlfaq9.pod        3 Jan 2005 19:14:43 -0000
 <at>  <at>  -352,35 +352,38  <at>  <at> 

 =head2 How do I decode a CGI form?

-You use a standard module, probably CGI.pm.  Under no circumstances
-should you attempt to do so by hand!
+(contributed by brian d foy)

-You'll see a lot of CGI programs that blindly read from STDIN the
number
(Continue reading)

_brian_d_foy | 3 Jan 2005 20:13
Picon
Favicon

[NEW ANSWER] perlfaq5: How can I copy a file?


* Several people on the Perl Trainers suggested adding this
answer to perlfaq5.  

* I'll update perlfaq.pod once I commit this answer.

Index: perlfaq5.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq5.pod,v
retrieving revision 1.34
diff -u -d -r1.34 perlfaq5.pod
--- perlfaq5.pod        3 Jan 2005 18:43:37 -0000       1.34
+++ perlfaq5.pod        3 Jan 2005 19:10:08 -0000
 <at>  <at>  -106,6 +106,22  <at>  <at> 
 leaving a backup of the original data from each file in a new
 C<.c.orig> file.

+=head2 How can I copy a file?
+
+(contributed by brian d foy)
+
+Use the File::Copy module. It comes with Perl and can do a
+true copy across file systems, and it does its magic in
+a protable fashion.
+
+       use File::Copy;
+
+       copy( $original, $new_copy ) or die "Copy failed: $!";
+
+If you can't use File::Copy, you'll have to do the work yourself:
(Continue reading)

Tony Cook | 3 Jan 2005 23:59

Re: [NEW ANSWER] perlfaq5: How can I copy a file?

On Mon, Jan 03, 2005 at 11:13:36AM -0800, _brian_d_foy wrote:
> Index: perlfaq5.pod
...
> +Use the File::Copy module. It comes with Perl and can do a
> +true copy across file systems, and it does its magic in
> +a protable fashion.

s/protable/portable/


Gunnar Hjalmarsson | 3 Jan 2005 23:37
Favicon

Re: perlfaq9: How do I decode a CGI form?

_brian_d_foy wrote:
>    + I'm completely replacing this answer.  The previous version
>    was pretty aggressive and ranted about cargo-culting.  It also
>    digressed into a discussion of HTTP methods.
> 
>    + The new answer showcases CGI.pm, and gives a couple examples.
>    I'd like people to use it because it's easier, not because we
>    decreed it's use.

It's undoubtedly an improvement.
http://groups-beta.google.com/group/comp.lang.perl.misc/msg/eab4683cd6949531

>    + I also removed the reference to cgi-lib.pl.  It is 2005 now :)

That makes much sense as well. I think that the light-weight CPAN 
modules (CGI::Lite, CGI::Fast, CGI::Minimal) should be mentioned, though.

--

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

esr | 14 Jan 2005 09:23
Picon
Gravatar

problems in several man pages you maintain

This is automatically generated email about problems in a man page for which
you appear to be responsible.  If you are not the right person or list, tell
me and I will attempt to correct my database.

See http://catb.org/~esr/doclifter/problems.html for details on how and
why these patches were generated.  Feel free to email me with any questions.
Note: These patches do not change the mod date of any manual page.  You
may wish to do that by hand.

Problems with XML::Encoding.3pm:
(May reflect bugs in POD).

1. Unbalanced .RS or .RE macro

--- XML::Encoding.3pm-orig	2004-01-02 14:01:20.000000000 -0500
+++ XML::Encoding.3pm	2004-01-02 14:01:33.000000000 -0500
 <at>  <at>  -188,10 +188,8  <at>  <at> 
 This will be 1 for the \*(L"ch\*(R" element. An undef value should be returned if
 successful. If in expat mode, a defined value causes an error and is used
 as the message string.
-.RS 4
 .SH "AUTHOR"
 .IX Header "AUTHOR"
-.RS 4
 Clark Cooper <\fIcoopercc <at> netheaven.com\fR>
 .SH "SEE ALSO"
 .IX Header "SEE ALSO"
-----------------------------
Problems with XML::Parser::Style::Objects.3pm:
(May reflect bugs in POD).
(Continue reading)

esr | 14 Jan 2005 09:27
Picon
Gravatar

problems in several man pages you maintain

This is automatically generated email about problems in a man page for which
you appear to be responsible.  If you are not the right person or list, tell
me and I will attempt to correct my database.

See http://catb.org/~esr/doclifter/problems.html for details on how and
why these patches were generated.  Feel free to email me with any questions.
Note: These patches do not change the mod date of any manual page.  You
may wish to do that by hand.

Problems with AnyDBM_File.3pm:
(May reflect bugs in POD).

1. There are multiple description lines.  This makes it impossible to
translate the page to DocBook.  It may also confuse some
implementations of man -k.

--- AnyDBM_File.3pm-orig	2004-11-17 23:10:32.174714560 -0500
+++ AnyDBM_File.3pm	2004-11-17 23:11:46.801369584 -0500
 <at>  <at>  -131,9 +131,7  <at>  <at> 
 .IX Title "AnyDBM_File 3pm"
 .TH AnyDBM_File 3pm "2001-09-21" "perl v5.8.5" "Perl Programmers Reference Guide"
 .SH "NAME"
-AnyDBM_File \- provide framework for multiple DBMs
-.PP
-NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File \- various DBM implementations
+AnyDBM_File, NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File \- framework for multiple DBMs, and
the implementations thereof
 .SH "SYNOPSIS"
 .IX Header "SYNOPSIS"
 .Vb 1
(Continue reading)

Eric S. Raymond | 18 Jan 2005 17:27
Picon
Gravatar

Blank manual pages in the Perl distro

Five times over the last year I have emailed notices to this list,
among other places, about manual pages that are ill-formed and
consequently cannot be correctly translated to XML-DocBook.

My campaign to drain this swamp has been remarkably successful.  Man
page maintainers have accepted around 300 fix patches to clean up
markup. Out of over 11000 manual pages in a full FC3 install, I can
now translate over 96% without patching and over 99% with fix patches.

There are exactly 57 manual pages left on my junk list.  In these,
the largest single group (14) is from the Perl documentation.  They are:

/usr/share/man/man3/B::Stash.3pm.gz
/usr/share/man/man3/Carp::Heavy.3pm.gz
/usr/share/man/man3/Encode::CJKConstants.3pm.gz
/usr/share/man/man3/Encode::CN::HZ.3pm.gz
/usr/share/man/man3/Encode::Config.3pm.gz
/usr/share/man/man3/Encode::JP::H2Z.3pm.gz
/usr/share/man/man3/Encode::JP::JIS7.3pm.gz
/usr/share/man/man3/Encode::KR::2022_KR.3pm.gz
/usr/share/man/man3/PDL::BAD2_demo.3pm.gz
/usr/share/man/man3/PDL::BAD_demo.3pm.gz
/usr/share/man/man3/PDL::Config.3pm.gz
/usr/share/man/man3/PDL::Doc::Config.3pm.gz
/usr/share/man/man3/XML::DOM-ecmascript.3pm.gz
/usr/share/man/man3/XML::SAX::PurePerl::Reader.3pm.gz

Fixing these pages should not be difficult. The following ones

PDL::BAD2_demo.3pm
(Continue reading)

_brian_d_foy | 26 Jan 2005 19:52
Picon
Favicon

perlfaq6: How do I efficiently match many regular expressions at once?


* updated the answer so that we don't think perl5.005 is the
newest version of perl

* cleaned up the examples to give them parallel structure and
to generalize the method.  (What was popstates anyway?)

* added another example

* mention Mastering Regular Expressions to motivate people to
find out how regexes work and that they can be tuned.

diff -u -d -r1.28 perlfaq6.pod
--- perlfaq6.pod        3 Jan 2005 18:43:37 -0000       1.28
+++ perlfaq6.pod        26 Jan 2005 18:48:13 -0000
 <at>  <at>  -518,32 +518,58  <at>  <at> 

 =head2 How do I efficiently match many regular expressions at once?

-The following is extremely inefficient:
+( contributed by brian d foy )

-    # slow but obvious way
-     <at> popstates = qw(CO ON MI WI MN);
-    while (defined($line = <>)) {
-       for $state ( <at> popstates) {
-           if ($line =~ /\b$state\b/i) {
-               print $line;
-               last;
-           }
(Continue reading)

_brian_d_foy | 26 Jan 2005 20:31
Picon
Favicon

perlfaq1: "Which version of Perl should I use?" and "What are perl4, perl5, or perl6?"


* "Which version of Perl should I use?"

   + I rewrote the answer to give general advice (use the latest
   stable version), but also to point out some of the trade-offs
   to consider

   + the updated answer knows that perl5.8.x is the recent stable
   version, and further emphasizes that perl4 is dead, dead, dead

   + I address perl6, but only to say that there is no need to
   worry just yet.

* "What are perl4, perl5, or perl6?"

   + This is a title change, adding perl6 to the answer

Index: perlfaq1.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq1.pod,v
retrieving revision 1.16
diff -u -d -r1.16 perlfaq1.pod
--- perlfaq1.pod  3 Jan 2005 18:43:37 -0000  1.16
+++ perlfaq1.pod  26 Jan 2005 19:27:41 -0000
 <at>  <at>  -56,39 +56,99  <at>  <at> 

 =head2 Which version of Perl should I use?

-You should definitely use version 5.  Version 4 is old, limited, and
-no longer maintained; its last patch (4.036) was in 1992, long ago and
(Continue reading)

_brian_d_foy | 26 Jan 2005 21:08
Picon
Favicon

perlfaq3: How can I free an array or hash so my program shrinks?

* Michael Carmen rewrote this answer to clarify some of the memory
management issues.  I usually don't pay attention to this level of
Perl and I'm not an OS guru, so an internals-type person may want
to verify the change.

Index: perlfaq3.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq3.pod,v
retrieving revision 1.44
diff -u -d -r1.44 perlfaq3.pod
--- perlfaq3.pod  21 Jan 2005 12:08:04 -0000 1.44
+++ perlfaq3.pod  26 Jan 2005 20:06:53 -0000
 <at>  <at>  -649,23 +649,25  <at>  <at> 

 =head2 How can I free an array or hash so my program shrinks?

-You usually can't. On most operating systems, memory
-allocated to a program can never be returned to the system.
-That's why long-running programs sometimes re-exec
-themselves. Some operating systems (notably, systems that
-use mmap(2) for allocating large chunks of memory) can
-reclaim memory that is no longer used, but on such systems,
-perl must be configured and compiled to use the OS's malloc,
-not perl's.
+(contributed by Michael Carman)
+
+You usually can't. Memory allocated to lexicals (i.e. my() variables)
+cannot be reclaimed or reused even if they go out of scope. It is
+reserved in case the variables come back into scope. Memory allocated
+to global variables can be reused (within your program) by using
(Continue reading)


Gmane