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

2011-01-15 Thread Saqib Ali
Thanks! This workaround worked for me. :) :)


- Saqib




On Tue, Jan 11, 2011 at 8:26 AM, Bob McConnell  wrote:

> 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.
>
> This sounds like you are running on a 32-bit OS. There is a fixed limit
> to how much memory each process can use, no matter how much RAM and swap
> space you have available. So the other option is to switch to a 64-bit
> system.
>
> Bob McConnell
>


Creating output report with topheader

2011-01-15 Thread Chris Stinemetz
I am having problems generating output report from my below program. I want to 
include the header format indicated in the program as well. A new output folder 
is being created but contains no data.

I am also getting the following warnings when I run the program (See far 
bottom). Any help is very appreciated!

#!/usr/bin/perl

use warnings;
use strict;
use FileHandle;

format DEVICE_REPORT =
@<< @| @| @| 
@|
my ($mkt, $mype, $cell, $sector, $rlptxat)
.

format DEVICE_REPORT_TOP =

@  Pg @<
"Smart Phone report",$%


MarketMobileCellSector   Bytes
-    
.

# Market configurations has for cells
my %marketInfo = (
MCI => { start => 1,
 end   => 299, },
STL => { start => 300,
 end   => 599, },
ICT => { start => 800,
 end   => 850, },
);

sub getMarket {

   my $val = shift;

   foreach my $k (keys %marketInfo) {
 my ($start, $end) = @{$marketInfo{$k}}{qw/start end/};
 return $k if $start <= $val and $val <= $end;
 write(DEVICE_REPORT);
   }

   return "";
}

open(DEVICE_REPORT, ">Device.rpt");

while () {
   chomp;
   if (/;/) {
 my @data = split /;/;
 my $mkt = getMarket($data[31]);
 my ($mtype,$cell,$sector,$rlptxat) = 
($data[5],$data[31],$data[32],$data[44]);
#print "$mkt\t  $mtype\t  $cell\t  $sector\t  $rlptxat\n";
   }
}



select(DEVICE_REPORT);
write(DEVICE_REPORT);

close(DEVICE_REPORT);

__DATA__
PACE | EVDOPCMD | 33.0 | 101218 | 07 |
8;1023240136;1218;0;1;00a01a2bcdc7;0310003147702376;ac016d4a;;;5.6.128.8;0;43234169;43234349;;;1;1;1;;0;;19;5.6.128.22;172.30.151.5;304;3;304;3;15;175;15;175;15;175;1;1798;1251;0;0;2;19;20;1;1;1;0;128;5.6.128.8;;;301;5.6.128.8;;;8;304;31;43244037;;;1;18;43234169;01;;43234416;0;0;304;3;21;19;175;15;405;1;1;1;1;0;125;1||
8;1023240137;1218;0;1;00a01db74ace;;ac0174ca;43243423;1678442111;5.6.128.8;1;0;;43242544;43244207;43243423;43243647;;;1000;1;1;;0;;19;5.6.128.26;;372;2;372;2;;43243012;0;43243562;15;175;15;175;15;175;1;5;48;19;20;49;50;;0;1;2;0;68;5.6.128.8;;;301;5.6.128.8;;;8;372;21;43244207;;;1;18;43243423;01;;;

Warnings I am getting:
Use of uninitialized value $mkt in formline at ./io.pl line 9,  line 2.
Use of uninitialized value $mype in formline at ./io.pl line 9,  line 2.
Use of uninitialized value $cell in formline at ./io.pl line 9,  line 2.
Use of uninitialized value $sector in formline at ./io.pl line 9,  line 2.
Use of uninitialized value $rlptxat in formline at ./io.pl line 9,  line 
2.
Chris Stinemetz



Re: doubt in substring

2011-01-15 Thread John Delacour
On 15 January 2011 07:52, Emeka  wrote:

> # 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?

Because you can't use single quotes for the script-string in Windows
cmd.exe.  If you must work in the command line, then you can either
escape all your double quotes within the string or use
qq~double-quoted string~ , where "~" can be any ascii character that
is not in the string itself.

perl -le "$str =  qq~the cat sat on the mat~; print substr( $str, 4, -4 )"

If I were beginning with Perl, I certainly would not practise in the
console but get an editor, such as  SciTE



and run the scripts from the editor (using F5) in the case of SciTE.

JD

-- 
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-15 Thread Emeka
*If I were beginning with Perl, I certainly would not practise in the
console but get an editor, such as  SciTE*
Yes, I am.

On Sat, Jan 15, 2011 at 3:04 PM, John Delacour wrote:

> On 15 January 2011 07:52, Emeka  wrote:
>
> > # 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?
>
> Because you can't use single quotes for the script-string in Windows
> cmd.exe.  If you must work in the command line, then you can either
> escape all your double quotes within the string or use
> qq~double-quoted string~ , where "~" can be any ascii character that
> is not in the string itself.
>
> perl -le "$str =  qq~the cat sat on the mat~; print substr( $str, 4, -4 )"
>
> If I were beginning with Perl, I certainly would not practise in the
> console but get an editor, such as  SciTE
>
> 
>
> and run the scripts from the editor (using F5) in the case of SciTE.
>
> JD
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*Satajanus  Nig. Ltd


*


Re: doubt in substring

2011-01-15 Thread Dr.Ruud

On 2011-01-15 08:52, Emeka wrote:


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.


On Windows it should probably look like:

# perl -wle "$s=q{abc def ghi jkl};print substr($s,4,-4)"

(untested)

--
Ruud

--
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-15 Thread Kenneth Wolcott
On Sat, Jan 15, 2011 at 03:20, Dr.Ruud  wrote:
> On 2011-01-15 08:52, Emeka wrote:
>
>> 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.
>
> On Windows it should probably look like:
>
> # perl -wle "$s=q{abc def ghi jkl};print substr($s,4,-4)"
>
> (untested)
>
> --
> Ruud

That worked for me on the Windoze console.

Ken Wolcott

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