Re: How to avoid Out of Memory Errors when dealing with a large XML file?

2011-01-14 Thread Jenda Krynicky
From: Saqib Ali 
> I'm reading a large (57 MB) XML file Using XML::XPath::XMLParser()
> 
> I keep getting this error:
> 
> "Callback called exit at XML/XPath/Node/Element.pm at line 144 during
> global destruction."
> 
> I'm using Windows XP. So I watched the task-management memory meter
> during the execution of this process. The PERL process chewed up a lot
> of the "available memory". But when the process died, it still showed
> about 216MB available memory.
> 
> Is there anything I can do to work-around this problem? From reading
> responses to other similar questions, the only option may be to use a
> XML stream parser instead of one that builds the entire DOM tree
> internally.

It might be best to switch to XML::Twig instead. It should be a 
simpler change than to go "stream based". XML::Twig allows you to 
read the file in chunks giving you the tree for part of the XML.

Hard to say without knowing the XML and what you need to do with it.

Jenda
= je...@krynicky.cz === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: doubt in substring

2011-01-14 Thread Emeka
Setting environment for using XAMPP for Windows.

rmicro@RMICRO-PC C:\Program Files\xampp
# perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
Can't find string terminator "'" anywhere before EOF at -e line 1.

rmicro@RMICRO-PC C:\Program Files\xampp
#

It failed to work for me. Why?



rmicro@RMICRO-PC C:\Program Files\xampp
# perl -v

This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.




On Thu, Jan 13, 2011 at 3:16 PM, Shawn H Corey wrote:

> On 11-01-12 11:27 PM, Sunita Rani Pradhan wrote:
>
>> I have a string as; $str =  "the cat sat on the mat" .
>>
>>
>>
>> How the following command works substr($str , 4, -4)  on the string ?
>> What should be the output?
>>
>
> TITS (Try It To See)
>
> perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
>
>
> --
> Just my 0.0002 million dollars worth,
>  Shawn
>
> Confusion is the first step of understanding.
>
> Programming is as much about organization and communication
> as it is about coding.
>
> The secret to great software:  Fail early & often.
>
> Eliminate software piracy:  use only FLOSS.
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*Satajanus  Nig. Ltd


*