Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
As anonymous before me stated, use subroutines to break up your program into smaller more manageable chunks. Then try to optimize each segment. Not only will this get you closer to solving your problems and more than likely eliminate alot of the memory usage along the way, but it will allow you to post a more concentrated chunk of code that is more likely to attract the attention of the monks.

From perlfaq3:

     "When it comes to time-space tradeoffs, Perl nearly always prefers to throw memory at a problem. Scalars in Perl use more memory than strings in C, arrays take more than that, and hashes use even more."

You have created an enormous amount of temporary scalars that are all named very similarly (i.e.  $c1..$c39) and used in very repetitive code. To start off, maybe try creating a subroutine to handle those more efficiently.
sub extract { my @arrays = (\@right, \@legal, \@prod); foreach 1..39 { foreach my $col ($_) { next unless defined $Sheet->Cells($row, $col)->{'Value'}; my $c = $Sheet->Cells($row, $col)->{'Value'}; map {push @$_, $c} @arrays; } } }

This is just an example, but I'm sure if you go through your program you'll be able to find multiple situations where things can be cut down and made faster, simpler, and easier to maintain/read.
It might do you well to clean up your comments, and include a sample of the data you plan on working with before making a post like this. It'll increase the likelihood that you'll get help from the guys that know most. You might try reading How (Not) To Ask A Question. Good Luck!

In reply to Re: Out of memory and While replacements with excel XLSX application by marquezc329
in thread Out of memory and While replacements with excel XLSX application by Weinstar

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [shmem]: good morning monkses and monksisses
    [choroba]: Good morning!
    [shmem]: GDPR meets butcher's shop
    [marto]: if only Spectre had remained a fictional organisation :P https://www. php?page=news_item &px=Spectre-V3-V4- Vulnerabilities
    [marto]: 'GDPR meats butcher's shop'?

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (7)
    As of 2018-05-22 07:21 GMT
    Find Nodes?
      Voting Booth?