I am using the following code to parse large code (> 50GB):
< Pre> XML :: Parser; My $ p = New XML :: Parser ('Handlers' = & gt; {'Start' = & gt; & amp; handle_start, 'end' = & gt; & amp; handle_end; 'four' = & Gt; \ & amp; handle_char,}); $ P- & gt; Parasfoil ('source.xml'); ... sub handle_start {...} The problem is that it takes a lot of time to parse, and I have to get some kind of progress meter.
I like a method that does not need to scan the entire file to get a full count - so, for example, the current position in the input file would be correct, because I only created the initial file , And then check the current status in handle_start (), and print it.
You might <
Code> $ my_size = - S $ input_file;
And then calculate your progress in this type of handler:
sub-handle_start {my ($ parser, $ element) = @_; My $ pos = $ parser- & gt; Current_byte; Printf ("% - 20s% 5.1f %% \ n", $ element, $ pos * 100 / $ file_size); }
Comments
Post a Comment