Jeff Westman wrote:
> I'm trying to help out another developer with a mini-Perl script.
> He has a file that contains one very long line, about 28M in size.
> He needs to do a replacement of all occurances of
>
> |^NEWLINE^|^
>
> to a literal newline (HPUX, 0x0a or "\n").
>
> When I ran this
>
> $ perl -ne 's/|^NEWLINE^|^/\n/g;print' loadFile
>
> it choked and gave me
>
> Out of memory during "large" request for 1073745920 bytes, total
> sbrk() is 604078796 bytes at -e line 1, <> line 1.
>
if your system do not have memory to read in large chunk, you can easily
break the chunks up by reading smaller chunks to process. for example, the
follwoing reads 4k a time and process them:
[panda]# perl -ne 'BEGIN{$/=\10} s/\|\^NEWLINE\^\|\^/\n/g; print' loadFile
david
--
sub'_{print"@_ ";* \ = * __ ,\ & \}
sub'__{print"@_ ";* \ = * ___ ,\ & \}
sub'___{print"@_ ";* \ = * ____ ,\ & \}
sub'____{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>