Whenever a variable is used in Perl, it occupies some memory space. Since the computer has limited memory the user must be careful of the memory being used by the program. For Example:
use strict;
open(IN,"in");
my @lines = <IN>
close(IN);
open(OUT,">out");
foreach (@lines)
{
print OUT m/([^\s]+)/,"\n";
}
close(OUT);
On execution of above program, after reading a file it will print the first word of each line into another file. If the files are too large then the system would run out of memory. To avoid this, the file can be divided into sections.