Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: perl script eats all my PC memory...

by Ea (Chaplain)
on Feb 20, 2015 at 17:41 UTC ( [id://1117362]=note: print w/replies, xml ) Need Help??


in reply to perl script eats all my PC memory...

From the dates in the file header, this looks like a file you've inherited. Perhaps the first thing to do is write a small script that just contains this
my @satfile = <STDIN>; my @satseq = @satfile;
and see if it runs out of memory. If so, your datafiles are too big to read in and make a copy and you'll want to deal with one line at a time, e.g.
my $sorsz = 3; while (my $line = <STDIN>) { chomp $line; # to remove newlines if ( $. <= 3 ) { # input line numbers start from 1 push @satseq, $line; } elsif ( $line =~ /\#/ ) { $satseq[$sorsz] .= $line; # concatenates line onto the end $sorsz++; } else{ $satseq[$sorsz] .= $line; } }
which is a more memory efficient way to deal with large files.

If the concatenation is still killing memory, try substr($satseq[$sorsz],length($satseq[$sorsz]),0) = $line

Sometimes I can think of 6 impossible LDAP attributes before breakfast.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1117362]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-23 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found