Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running a Perl script that parses information from around 7,000 HTML files. Probably not really relevant, but I'm just trying to describe that this is, well, doing a lot of stuff. I originally had them just print out the information I was looking for right into the terminal and then I pasted that into my spreadsheet. However, about half way through, I was told that I was out of memory and it stopped.

Out of memory! - nothing else

I Googled, but I couldn't find anything that talked about the terminal specifically printing this. I could find posts related to Linux about just generally running out of memory, but I wanted to be sure. I've tried, with no success, to have it write to a .txt file instead of printing out into the terminal.

How can I fix this and let the Perl script run all the way through?

share|improve this question

closed as off topic by qbi, hhlp, Scaine, Eric Carvalho, Rafał Cieślak Jan 13 '13 at 21:32

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Without seeing your code, I would recommend that you head over to perlmonks.org and post your code. Sorry I couldn't help more. Perl will take all the memory that you give it. –  Kevin Bowen Dec 28 '12 at 8:00
4  
You might want to migrate this question to stackoverflow.com and provide some code. –  Victor Dec 28 '12 at 17:12

1 Answer 1

up vote 1 down vote accepted

Instead of fighting with perl optimization, use a wrapper like this:

wrapper.sh

#!/bin/bash

for i in `ls $1`
do
    echo $i
    <perl script> $i
done

Use it as follows:

./wrapper.sh *.html

So instead of the perl script looping through 7k of files in one run, it is a fresh start for each file.

I also suggest you redirect the output into a file instead of the screen. It is possible that the terminal (xterm, gnome-term, etc) used up all your memory if set to unlimited buffer/lines.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.