Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!wuarchive!cs.utexas.edu!ut-emx!ccwf.cc.utexas.edu From: dboles@ccwf.cc.utexas.edu (David Boles) Newsgroups: comp.lang.perl Subject: pattern matching question Message-ID: <49420@ut-emx.uucp> Date: 23 May 91 18:58:44 GMT References: <1991May22.193037.12166@cherokee.uswest.com> <1991May22.221507.12660@cherokee.uswest.com> Sender: news@ut-emx.uucp Reply-To: dboles@ccwf.cc.utexas.edu (David Boles) Organization: The University of Texas at Austin Lines: 54 Warning: PERL NOVICE approaching !!! I am trying to do the following file manipulation: p220 p220 20 5 p220 p235 20 7 etc. ==> p220 -20 -5 p220 20 5 p220 -20 -7 p235 20 7 etc. I am using: while (<>) { s/(p\d*) (p\d*) (\d*) (\d*)/$1 -$3 -$4\n$2 $3 $4\n/; print; } and I get: p220 - - p220 20 5 p220 - - p235 20 7 etc. If I take away the minus signs in the replacement string, I just get: p220 p220 20 5 p220 p235 20 7 etc. Why aren't $3 and $4 "alive" in the first half of the replacement string? What am I missing? Thanks! David Boles -- ------------------------------------------------------------------------------- David Boles Applied Research Laboratories dboles@ccwf.cc.utexas.edu apas611@chpc.utexas.edu This space for rent, apply within. -------------------------------------------------------------------------------