deb wrote: > Hi, > > I am modifying a file and replacing a string that I find, which works > just fine. However, sometimes there is already a string there that I > don't want to replace, but instead append something to it. > > Here's what I've got so far: (obligatory use statements not included > here) > > while (<IN>) { > > s/^This_Text.*$/That_Text = 2/; > > } > > But now, I may already have "That_Text = 2" which I don't want to > replace, but instead append ":New_Text = 4". > > What would be a good method for post-appending text? What about > something like this? (Seems kind cumbersum.) > > my $addText = ":New_Text = 4"; > > while (<IN>) { if ( /^That_Text\s=\s2/ ) { $_ .= $addText; }else { s/^This_Text.*$/That_Text = 2/; } You don't need the $_ since this is the default for regex searches and replaces. Wags ;) > > > Recommendations? > > Thanks, > > d
********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]