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 ( $_ =~ /^This_Text/) {
>                 my $text =~ /^*$/;

Should probably be:
                my $text =~ $_ . $addText

> }

Then you have to decide how to put $text to use.  I'd suggest write-and-rename.

> Recommendations?
>
> Thanks,
>
> d

Joseph



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

Reply via email to