in reply to Show error "Out of Mermory"!!
or save the $mech->get($login_url) directly to a file by adding in ':content_file' => 'somefile'use Data::Dumper; use XML::Simple; use WWW::Mechanize; $| ++; #making hot the pipe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Show error "Out of Mermory"!!
by Anonymous Monk on Oct 12, 2009 at 10:29 UTC | |
Hi biohisham, Thanks for reply i also done by saving xml in file but the problem("OUT OF MEMORY") didn't solve. So please tell any other way to solve out it. Could u tell me what's "Pseudo-hashes are deprecated" and how to solve it. I am new to perl so that have so many problem.
| [reply] [d/l] |
by almut (Canon) on Oct 12, 2009 at 12:41 UTC | |
You've told XML::Simple to "ForceArray" (i.e. to always create arrays, even if there is only one element). Thing is that ForceArray expects a boolean value, so as you have ForceArray => 'srw_dc:dc', you've enabled the feature globally (not only for 'srw_dc:dc' as the idea might have been...) That means you have to access the resulting data structure accordingly, i.e. explicitly specify all array indices
(note the [0] in between the fields 'records' and 'record') Update: the thing with the "Pseudo-hashes are deprecated" is as follows: in short, as pseudo-hash is an array with a hash in its first element (index 0) that is being used to lookup the array indices to be used for the individual pseudo-hash fields (this applies to Perl versions < 5.10 only, btw). E.g.
When you, for example, write
the resulting data structure would look like
Two things to note: (1) the pseudo-hash field 'key' maps to array index 5, and (2) the array is automatically resized (as usual, with all indices less than 5 being created as undef). Now, XML::Simple (with ForceArray enabled) produces a data structure something like this
so when you write
the hash that holds 'record' is being used as pseudo-hash indexing array (as it is at index 0 of the 'records' => [...] array/pseudo-hash). And due to what I would call a bug in Perl, using the arrayref as the pseudo-hash-mapped index, doesn't produce an error message, but rather is interpreted as a (typically huge) number, which in turn leads to Perl auto-resizing the array (in this case because of autovivification) until it runs out of memory in your case... | [reply] [d/l] [select] |
by biohisham (Priest) on Oct 12, 2009 at 11:02 UTC | |
Saving to a file might not solve the problem, you haven't said whether you disabled buffering or not, you haven't shown that either. In Perl you got line-buffering and block-buffering, saving to files employs block buffering since print and write operations are involved hence sometimes you need to enforce a buffer flush every time a filehandle is written to in case you are afraid that memory issues would come-up. This link can be useful for you to learn more about buffering and for pseudo hashes, a quick googling around the place can give you an indication; Pseudo-hashes deprecated, pseudo hashes.. Perl is a lovable language, just be committed to it and do what it takes to get there. Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind. | [reply] [d/l] |
by Sachin (Acolyte) on Oct 12, 2009 at 11:56 UTC | |
Hi, i use
but it's showing "out of memory!!" message again. Following my jestor_1.xml file. Now i wants to print title from this file. so what i do??
| [reply] [d/l] [select] |