M Z wrote:
> hello all -
>
> I am trying to do the following to this data:
> input:
> X|Y||||Z||A
>
> desired output:
> X|Y| | | |Z| |A
>
> simply replacing || with | |
> whereever it may occur in the string.
>
> This bit of code doesn't seem to do all of the job.
>
> What is wrong with this code?
>
> while (<>) {
> while($_ =~ /([|])([|])/g) {
> $_ =~ s/([|])([|])/$1 $2/g;
> print "$_";
> }
> }
>
> The problems seems that my bit of code doesn't
> completely catch "all" of the || occurences within a
> given line.  Please help!!!

You've been shown what's wrong, but as for a solution
how about this.

  while (<DATA>) {
    1 while s/\|\|/| |/;
    print;
  }

  __DATA__
  X|Y||||Z||A

OUTPUT

  X|Y| | | |Z| |A



HTH,

Rob





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

Reply via email to