Hello
I am not sure,
<change $line, making sure the length (in bytes) doesn't
change>
what does this mean? not changing the line length?
but in most case I need to change the length of a line.
Thanks again.
Tom
> That sounds positive. You should be able to avoid most of the overhead of
> writing the file. The general idea is that you are "updating in place"
> rather than writing out the whole file.
>
> Something like below is what I was thinking, but it isn't tested! Make
> sure you have a copy of your input file. Oh, and I haven't thought about
> "wide" characters which may influence how some of this works.
>
> Cheers,
>
> Claude.
>
>
> open(my $fh, "+<", $theFileName) or die "open: $!";
>
> my $startOfLine = tell($fh) or die "tell: $!;
> while (defined(my $line = <$fh>))
> {
> if ($line has content that needs to change)
> {
> <change $line, making sure the length (in bytes) doesn't change>
> seek($fh, $startOfLine, 0) or die "seek: $!";
> print $fh $line;
> }
>
> $startOfLine = tell($fh) or die "tell: $!;
> }
>
> close($fh);
>
>
> -----Original Message-----
> From: Tom Reed <[email protected]>
> Sent: Wednesday, May 31, 2023 9:33 AM
> To: Claude Brown <[email protected]>
> Cc: [email protected]
> Subject: RE: storage types for big file
>
>
>
>> Do you have the option to "seek" to the correct place in the file to
>> make
>> your changes? For example, perhaps:
>>
>> - Your changes are few compared to writing out the whole file
>> - Your changes do not change the size of the file (or you can pad
>> line-end
>> with spaces)
>>
>
> 1. each time just changes few lines, not the full file.
> 2. it has file size changed, but yes I can pad line-end with space.
>
> So what's the further?
>
> Thanks
>
>
> --
> Sent from https://dkinbox.com/
>
>
> --
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
>
--
Sent from https://dkinbox.com/
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/