* This one time, at band camp, henry said:
> Dear List:
>     I use split to parse string 
> as follows:
> 
>      #!/usr/bin/perl -w
>      $record ="Pacific:ocean"
>      my($a,$b)=split(/:/,$record);
>      print "$a\n";
>      print "$b\n";
> 
>     My problem is :
>         In practical use , I usually get 
>                                     $record = "             a :        b" ;
> 
>     How do I  take out those blanks ?
>     

Well, in this example you are putting new lines in the print statements (the
\n's) and it should have printed 
Pacific
ocean

However, ignoring those small points, if you want to trim off white space
you can use the following :

# Trim off white space from the front of the line
$var =~ s/^\s*//;

# Trim off white space from the end of the line
$var =~ s/\s*$//;

HTH

Greeno
-- 
Greeno <[EMAIL PROTECTED]>
GnuPG Key :  1024D/B5657C8B 
Key fingerprint = 9ED8 59CC C161 B857 462E  51E6 7DFB 465B B565 7C8B

Imagine working in a secure environment and finding the string 
_NSAKEY in the OS binaries without a good explanation
    -Alan Cox 04/05/2001
-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to