in reply to add character to all lines starting with..
Or if you want to do it programmatically and are working with relatively small files then make use of Dominus' marvellous Tie::Fileperl -pi -e 'm{^/index} and s/$/%/' file
And if you're working with large files then this might be a better solutionuse Tie::File; tie my @fl, 'Tie::File', "filename.here" or die "ack: $!"; for(@fl) { m{^/index} and s/$/%/; }
open(my $in_fh, '<', "input.filename") or die "ack: $!"; open(my $out_fh, '>', "output.filename") or die "ack: $!"; while(<$in_fh>) { m{^/index} and $_ .= "%"; print {$out_fh} $_; } close $in_fh; close $out_fh; rename( "output.filename", "input.filename" ) or die "ack: $!";
_________
broquaint
update: have fixed code to DTRT, thanks to delirium
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: add character to all lines starting with..
by delirium (Chaplain) on Sep 24, 2003 at 20:31 UTC |