http://www.perlmonks.org?node_id=1018723

shan_emails has asked for the wisdom of the Perl Monks concerning the following question:

Hi All

I need to read the contents of the file (2 GB file size) in unix box and then assign into a variable. That time it shows Out of memory error. How to handle this scenario

bash-2.00$ uname HP-UX bash-2.00$ ulimit -a core file size (blocks) 2097151 data seg size (kbytes) 1048576 file size (blocks) unlimited max memory size (kbytes) unlimited open files 2048 pipe size (512 bytes) 16 stack size (kbytes) 256000 cpu time (seconds) unlimited max user processes 5001 virtual memory (kbytes) unlimited

And my code is

my $contents; open(my $fh, '<', 'control_report_file') or die "cannot open file cont +rol_report_file $!"; { local $/; $contents = <$fh>; } close($fh);
bash-2.00$ perl test.pl Out of memory!

Please, some help would be much obliged!

Thanks

Shanmugam A.