Re: Modify File in Place
- From: Paul Lalli <mritty@xxxxxxxxx>
- Date: 27 Apr 2007 10:40:39 -0700
On Apr 27, 1:34 pm, banker123 <bradbrock...@xxxxxxxxx> wrote:
local $^I = q{};
local @ARGV = ('E:/Remitrac/PDD/rmtd07110/Transmit/712531.dat');
while (<>) {
if(/^04/){
my $aux = (split/,/)[7];
$aux=~ s/^0+//;
print;
}
}
Can not do in place edit without backup error?
You did not mention you are on Windows. That's relevant. In that
case, you have to give $^I an actual value, say ".bkp", to create the
back up. Then you're free to remove that backup when the script ends.
Also I want this
script to edit the variable as defined above and leave all other
records in the file with the existing file name.
That's not what your original script did. Your original script was
only printing the $arg value, not anything else. Please take more
care to compose your posts, and you'll get better help.
{
local $^I = '.bkp';
local @ARGV = ( 'data.txt' );
while (<>) {
if (/^04/) {
my @vals = split / ,/;
$vals[7] =~ s/^0+//;
$_ = join(' ,', @vals);
}
}
continue {
print;
}
}
.
- Follow-Ups:
- Re: Modify File in Place
- From: nobull67@xxxxxxxxx
- Re: Modify File in Place
- References:
- Modify File in Place
- From: banker123
- Re: Modify File in Place
- From: Paul Lalli
- Re: Modify File in Place
- From: banker123
- Modify File in Place
- Prev by Date: Re: Modify File in Place
- Next by Date: Re: improving my code: array of references
- Previous by thread: Re: Modify File in Place
- Next by thread: Re: Modify File in Place
- Index(es):
Relevant Pages
|
|