> -----Original Message-----
> From: Mark Martin [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 08, 2001 10:01
> To: [EMAIL PROTECTED]
> Subject: Substitution Problem
>
>
> Hi,
> I'm taking in a csv file and splitting it. One of the fields(doc) could
> possibly have six spaces which will disrupt the program later on so I need
> to substitute in dummy values. $doc == "      " finds the "empty" fields
> okay but the substitution doesn't work. Clear as Mud?? Any ideas?
>
> open (FILEHANDLE,$file);
>
>
> while (<FILEHANDLE>){
>
> chomp;
>
> ($type,$doc,$narrative,$amount,$bdate,$branch) =
> split(/,/);
>
> if ($doc == "      "){
>
>          doc =~ s/      /111111/;
First of all you should use eq instead of == when comparing strings.
You can also omit the if, or dont use a substitute.
What you are sayinf now is: If $doc equals some spaces, then search and
replace some spaces with some zero's.

is would try this:

$doc =~ s/\s\1\g unless $doc;

Maarten.

Reply via email to