Oops, I sent that before I was done (sliped with the fingers).

The first is more efficient, the second is less typing.

....And actually the second one is incorrect, it should be this:

$value =~ s/^\s*(.*)\s*$/$1/;

You need to use \s* because one of them might match a space and the other
might not.  The way you had it would only with if there was both a leading
and trailing whitespace char(s).

But yes, either will work... although most will recommend the first option
due to performance (although it is minimal unless the string is very large).

Rob

-----Original Message-----
From: Hanson, Robert 
Sent: Thursday, February 14, 2002 12:36 PM
To: 'David Gilden'; [EMAIL PROTECTED]
Subject: RE: removing white space


The first is more efficient, the second is less typing.

....And actually the second one is incorrect, it should be this:


Rob

-----Original Message-----
From: David Gilden [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 12:29 PM
To: [EMAIL PROTECTED]
Subject: removing white space

Is this correct, I want to remove leading and trailing white space,
Thanks

Dave
--------------

foreach $item (param()) {
my $value = param($item);
$value =~ s/^\s+//;
$value =~ s/\s+$//;
}

better??
foreach $item (param()) {
my $value = param($item);
$value =~ s/^\s+(.*)\s+$/$1/;
}



-------------

#!/usr/bin/perl 

use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use POSIX 'strftime';

$mailprog = '/usr/lib/sendmail';


# Retrieve Date
$date = strftime('%A, %B %1d, %Y %I:%M %p',localtime) ,"\n";


# my %in = {};

# remove any extra spaces at the front or back 

foreach $item (param()) {
my $value = param($item);
$value =~ s/^\s+//;
$value =~ s/\s+$//;
}


$email = param('email');
$realname = param('name');

*====================================================*
*   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]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to