Ok Rob, I'll have a look. Thanks! jlc
-----Original Message----- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Thursday, July 12, 2007 1:22 PM To: beginners@perl.org Cc: Joseph L. Casale Subject: Re: Search and Replace Joseph L. Casale wrote: > > How can I make this expression: > $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/ > > Add some numerical value to the Z$3 part, so if $3 > was 3.14, I want it to be Z4.14 for example by adding 1 to it. May I reply amending my original solution to your problem, which seems to me to suit your purpose better? In the code below the value that would have been held in $3 is in $z, so the extra line of code simply increments it by one. HTH, Rob use strict; use warnings; while (<DATA>) { my ($x, $y, $z) = split; $z += 1; printf "X%s Y%s Z%s\n", $x, $y, $z; } __DATA__ -11.67326 23.95923 0.4617566 5.075023 24.27938 0.4484084 6.722163 -24.68986 1.399011 -11.2023 -25.0398 1.145933 **OUTPUT** X-11.67326 Y23.95923 Z1.4617566 X5.075023 Y24.27938 Z1.4484084 X6.722163 Y-24.68986 Z2.399011 X-11.2023 Y-25.0398 Z2.145933 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/