On Mon, Apr 30, 2001 at 12:06:55PM +0100, Gary Stainburn wrote:
> Hi all,
> 
> can anyone tell me why the following code does not come out with 
> '-123.45'.  It actually comes out with '123.45-'.
> 
> I think that it is because it's treating it as a number at some point, 
> but I can't see when/why.
> 
> #!/usr/bin/perl -w
>  
> my $vat='123.45CR';
>  
> $vat=~s/(\.*)CR/-$1/i;

Let's look at this regex:

  (     begin grouping
  \.*   zero or more literal periods
  )     end grouping
  CR    the literal characters 'CR'

Since $vat never contains the sequence ".CR", $1 never
gets filled.

Perhaps you want s/(.*)CR/-$1/ instead?

-- 
Never hit anyone with glasses.  Instead, use your fist.

Reply via email to