By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,812 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,812 IT Pros & Developers. It's quick & easy.

Out of memory

P: 7
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
Share this Question
Share on Google+
5 Replies


Icecrack
Expert 100+
P: 174
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 2.5K+
P: 4,059
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

P: 7
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 2.5K+
P: 3,503
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+
P: 174
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.