467,179 Members | 1,228 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

Out of memory

Can some body help me why I am getting "out of memory error". Below is the code I am trying to execute. Mu input xml file is 300KB size.
Expand|Select|Wrap|Line Numbers
  1. use XML::Simple;
  2.  
  3. #assigne variables
  4. my @engines = (1,2,3,4,5);
  5.  
  6. open(OUTPUT, "> "output_file.txt") or die "Can't open output_file.txt") for write: $!";
  7.  
  8. # create object
  9. $xml = new XML::Simple;
  10.  
  11. # read XML file
  12. my $data = $xml->XMLin("input.xml",KeyAttr => "number");
  13.  
  14.  
  15. foreach $n (@engines)
  16.  
  17. {
  18.  print OUTPUT "***************\n";
  19.  print OUTPUT "Engine $n \n"; 
  20.  print OUTPUT "***************\n";
  21.  print OUTPUT  $data->{Job}->{Step}->{5000}->{Action}->{Engine}->{$n}->{Error};
  22. }
  23.  
  24. # print the final totals listing
  25.  
  26. print OUTPUT "****************\n";
  27. print OUTPUT "Final Totals    \n";
  28. print OUTPUT "****************\n";
  29. print OUTPUT $data->{Job}->{Step}->{5000}->{Action}->{Engine}->{Log};
  30. print OUTPUT $data->{Job}->{Step}->{7000}->{Action}->{Engine}->{Log};
  31. print OUTPUT $data->{Job}->{Step}->{9000}->{Action}->{Engine}->{Log};
  32.  
  33. close OUTPUT;
  34.  
Oct 1 '08 #1
  • viewed: 2146
Share:
5 Replies
Icecrack
Expert 100+
first off please use code tags


Expand|Select|Wrap|Line Numbers
  1. open(OUTPUT, "> "output_file.txt") or die "Can't open output_file.txt") for write: $!";
  2.  
problem could be here


Expand|Select|Wrap|Line Numbers
  1. open(OUTPUT, ">", "output_file.txt") or die "Can't open output_file.txt for write: $! ";
as well we will need some sample input.xml code to help you more
Oct 1 '08 #2
KevinADC
Expert 2GB
if this line is literally written like this:

Expand|Select|Wrap|Line Numbers
  1. open(OUTPUT, "> "output_file.txt") or die "Can't open output_file.txt") for write: $!";
It will just cause the script to abort with an error so I can't see how that would cause an out of memory error.

Add this to your code:

Expand|Select|Wrap|Line Numbers
  1. use warnings;
Oct 1 '08 #3
if this line is literally written like this:

Expand|Select|Wrap|Line Numbers
  1. open(OUTPUT, "> "output_file.txt") or die "Can't open output_file.txt") for write: $!";
It will just cause the script to abort with an error so I can't see how that would cause an out of memory error.

Add this to your code:

Expand|Select|Wrap|Line Numbers
  1. use warnings;
Expand|Select|Wrap|Line Numbers
  1. open(OUTPUT, "> "output_file.txt")  This line is actually
  2.  open(OUTPUT, "> output_file.txt") 
  3.  
I typed it wrongly while posting. Sorry.
Oct 2 '08 #4
numberwhun
Expert Mod 2GB
Ok, Icecrack was kind enough to ask you to please use code tags, I have fixed your first post and now, your latest post STILL has no code tags.

The code tags are NOT an option and are required. You need to please read the Posting Guidelines for this site.

This is your only warning after having been asked to use them.

Regards,

Jeff (Moderator)
Oct 2 '08 #5
Icecrack
Expert 100+
Expand|Select|Wrap|Line Numbers
  1. open(OUTPUT, "> "output_file.txt")  This line is actually
  2.  open(OUTPUT, "> output_file.txt") 
  3.  
I typed it wrongly while posting. Sorry.
as posted above we will need some sample of your xml file or the whole.
this way we can test it, and see if its your site or its the scirpt.


Thank you.
Oct 2 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Frank Esser | last post: by
4 posts views Thread by Franklin Lee | last post: by
9 posts views Thread by Mike P | last post: by
22 posts views Thread by xixi | last post: by
14 posts views Thread by Alessandro Monopoli | last post: by
1 post views Thread by Nick Craig-Wood | last post: by
1 post views Thread by Jean-Paul Calderone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.