in reply to Long string needs to be separated

Good thing memory grows on trees these days ...
use strict; open(FH, "really_big_file") or die("doh - $!"); my $filestr = do { local $/; <FH> }; $filestr =~ s/(.{150})/$1\n/gs;
This puts the whole file in $filestr, then sticks a \n after every 150 characters. After that you'll probably want to put $filestr somewhere (probably not the original file in case you trample the data :-)
HTH

broquaint

Update: Ok, per trs80's node I should warn you that this is not a great solution as it will undoubtedly be quite slow and take up large amounts of memory (i.e > than the 25MB file size). But if you've got time and hardware on your hands, TMTOWTDI.

Replies are listed 'Best First'.
Re: Re: Long string needs to be separated
by trs80 (Priest) on Feb 13, 2002 at 17:03 UTC
    It is not a good idea to slurp 25MB into memory for modifying. It will be faster to use some kind of buffered read vs. a slurp. Even if you have the hardware to handle a file that size in memory.
    I won't argue that this could solve the problem, it just isn't a good habit to get into when dealing with larger files. Ask me how I know :^)