Is the following regrex the correct way to remove leading or trailing white space
from a string?

$data = "    [EMAIL PROTECTED] (mike smith)    "

$data =~ s/(^\s+)|(\s+$)//g;

or would it be more efficient to it thus:

# two passes
$data =~ s/^\s+)//;
$data =~ s/\s+$)//;

Final comment when I am reading from a loop:


open(EL,"$emailLog") ||  &errorLog( "Read in, Could not find $emailLog, $!");
my @lines = <EL>;

 foreach(@lines){
    next if /test/; 
    $_ =~ s/^\s+(.*)\s+$/\1,/; 

.... other code....

Do I need to escape the '@' as my data will be of format:
[EMAIL PROTECTED] (name) 


Thanks
Dave

Reply via email to