On Thu, 2 Jan 2014 23:21:22 +0800 (SGT) mani kandan <mani_nm...@yahoo.com> wrote:
> Hi, > > We have file size of huge size 500MB, Need to Manipulate the file, > some replacement and then write the file, I have used File::slurp and > works for file size of 300MB (Thanks Uri) but for this huge size > 500MB it is not processing and come out with error. I have also used > Tie::file module same case as not processing, any guidance. Firstly, be specific - "come out with error" doesn't help us - what is the error? Secondly - do you need to work on the file as a whole, or can you just loop over it, making changes, and writing them back out? In other words, do you *need* to hold the whole file in memory at one time? More often than not, you don't. If it's per-line changes, then File::Slurp::edit_file_lines should work - for e.g.: use File::Slurp qw(edit_file_lines); my $filename = '/tmp/foo'; edit_file_lines(sub { s/badger/mushroom/g }, $filename); The above would of course replace every occurrence of 'badger' with 'mushroom' in the file. Cheers Dave P -- David Precious ("bigpresh") <dav...@preshweb.co.uk> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/cpan www.preshweb.co.uk/github -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/