Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Eating RAM problem

by Abigail-II (Bishop)
on Aug 01, 2002 at 17:54 UTC ( [id://186867]=note: print w/replies, xml ) Need Help??


in reply to Eating RAM problem

Your problem isn't so much the file size, your problem is that you want to make an array element for every single character. This is Perl, not C, so this is going to be costly - you'll get the overhead of a "Perl value" for each character.

Do you really need that? Can't you use substr? Do you have to have all the characters of the file at the same time? Isn't the encryption/decryption algorithm made such that it encrypts/decrypts blocks of some decent size?

Abigail

Replies are listed 'Best First'.
Re: Re: Eating RAM problem
by TheFifthDeuce (Novice) on Aug 01, 2002 at 18:30 UTC
    Well yes, the algorhythm does work on blocks. I was using an anology for every byte of a 2 MB file, because that would still be the realistic equivilent of 32 byte size blocks of a 64 MB file. I guess I could put a max-restriction on the data that can be entered to encrypt.lol

    The point is is that I HAVE to have each chunk of 32 chars from the file to work with...whether I am using an array or not. How how can I do something like this using substr as you suggest, or for that matter, ANY way without draining RAM!lol
    sub get_data{ my(@chunks_of_32); @chunks_of_32 = (); open(FILE, $file) or die; while(<FILE>){ push @chunks_of_32, /\d{32}/og; } close(FILE); }
    Thanks
      Eh, why don't you just read in 32 characters, process them, write the output and then read in the next 32 characters?

      If you don't need the entire file at once, don't read it all at once.

      Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-18 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found