David, cgi-lib.pl and CGI.pm do the same things, for all intents and purposes. I've not bothered to use CGI.pm, in part because of its overly cumbersome style and kludges. But that's my preference. There are very few 'shoulds' in perl and far fewer 'musts.' CGI.pm over cgi-lib.pl is neither of those. :o>
So, for giggles, here's the problem solved in CGI.pm #!/usr/bin/perl use CGI; $q = new CGI; $q->header; %params = $q->Vars; foreach $key (keys(%params)) { $params{$key} = s/^\s+//; $params{$key} =~ s/\s+$//; } # # whatever else # And, equally for giggles, here's the same thing in cgi-lib.pl: #!/usr/bin/perl require 'cgi-lib.pl'; &ReadParse; print &PrintHeader; foreach $key (keys(%in)) { $in{$key} = s/^\s+//; $in{$key} =~ s/\s+$//; } # # whatever else # One involves less typing. It's also clearer in the eye of the beholder. -jdm >From: David Gilden <[EMAIL PROTECTED]> >To: John M <[EMAIL PROTECTED]>, [EMAIL PROTECTED] >Subject: Re: removing white space revisited >Date: Mon, 18 Feb 2002 14:13:34 -0500 > >That is kool, but I am using CGI.pm like we all should be :) > >On Monday, February 18, 2002 at 2:01 PM, [EMAIL PROTECTED] (John >M) wrote: > > > David, > > > > foreach $key (keys(%in)) > > { $in{$key} =~ s/^\s+//; $in{$key} =~ s/\s+$//; } > > > > That's all you have to do. > > > > -jdm > > > > (%in is generated under cgi-lib.pl) > >So back to my question do need to assign param() to hash? > >Thx, > >Dave > > > >From an earlier post: >This is great for 'Upper-casing' just the first letter of a string! > >#!/usr/bin/perl -w > >my $key ="today's Departure date"; >$key =~ s/([\w'-]+)/\u$1/g; > >print $key; >-------- > > > > > > > > >From: David Gilden <[EMAIL PROTECTED]> > > >To: [EMAIL PROTECTED] > > >Subject: removing white space revisited > > >Date: Mon, 18 Feb 2002 13:48:46 -0500 > > > > > >Hi, > > > > > >My goal is to clean up the fields submitted from a form and then be >able > > >to use them in other places. > > > > > >Does the following modify the value of param('name') -- if I have a >form > > >element named 'name' -- > > >permanently (like when you have an array) > > > > > > > > >foreach my $key (param()){ > > > > > >$val = param($key), > > >$value =~ s/^\s+//; > > >$value =~ s/\s+$//; > > >$key =~ s/\d$//; > > > > > > > > >print "$key: $val\n\n"; > > > > > > } > > > > > > > > >later in the script > > > > > >print param('email') # will this have been cleaned regrex in the up >the > > >loop above? > > > > > > > > >Do I have to assign my 'cleaned' data to a hash? > > > > > >Thanks! > > > > > >Dave > > > > > >*====================================================* > > >* Cora Connection Your West African Music Source * > > >* http://www.coraconnection.com/ * > > >* Resources, Recordings, Instruments & More! * > > >*====================================================* > > > > > >-- > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > _________________________________________________________________ > > MSN Photos is the easiest way to share and print your photos: > > http://photos.msn.com/support/worldwide.aspx > >*====================================================* >* Cora Connection Your West African Music Source * >* http://www.coraconnection.com/ * >* Resources, Recordings, Instruments & More! * >*====================================================* _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]