Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Out of memory error!!!

by McA (Priest)
on Mar 28, 2013 at 08:35 UTC ( #1025897=note: print w/replies, xml ) Need Help??


in reply to Re^2: Out of memory error!!!
in thread Out of memory error!!!

In your example you're opening a filehandle named XML, so I assume you want to convert your input stream to xml format. If this is right we would like to see how the xml output is produced. Probably you're using a memory intensive way.

McA

Replies are listed 'Best First'.
Re^4: Out of memory error!!!
by sathya83aa (Acolyte) on Mar 28, 2013 at 08:59 UTC

    Ok Let me make it more clear..Im fetching those variables from a flat file and printing it in the XML file. The order of printing of the variable will differ from how we are getting the variable.

    #!/usr/bin/perl

    open (my $INFO, "<", "$File") or die("Cannot open the flat file $!");

    open(my $LOG,">>LOG_file") or die("Cannot open $!");

    open(my $XML,">xml_file") or die("Cannot open $!");

    while (defined(my $line2 = $INFO)) {

        $line2 =~ s/&/&amp;/g;

        print "$line2\n";

        my $segment = substr($line2,0,2);

        if($segment eq "00")

        {

        my $Var1 = trim(substr($line2,40,8));

        }

        if($segment eq "A0")

        {

        $Var2 = trim(substr($line2,2,9));

        $Var3 = trim(substr($line2,14,3));

        $Var4 = trim(substr($line2,20,42));

        $Var5 = trim(substr($line2,62,30));

    and so on

    }

        print XML "<Header>\n";

        print XML "<AAA>VAR1<\/AAA>\n";

        print XML "<BBB>VAR2<\/BBB>\n";

        print XML "<CCC>VAR3<\/CCC>\n";

      print XML "<DDD>VAR4<\/DDD>\n";

      print XML "<EEE>VAR5<\/EEE>\n";

        print XML "<Header>\n";

    close $LOG;

    close $XML;

    close $INFO;

    sub trim($)

    {

       my $string = shift;

        $string =~ s/^\s+//;

       $string =~ s/\s+$//;

       return $string;

    }

      How much data do you have to collect to decide in which order you can generate the xml? Do you have to collect all records of the input file? Do you only have to collect a sequence of segments to create a - let's call it - xml record? Sorry, but your excerpt didn't help?

      How big is the input file?

      McA

        I have to collect data from all the lines in the input file and then print it to the XML file.

        Actually the input file is huge,..but now for testing we are using a input file with 30 lines for which we are getting the error.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025897]
help
Chatterbox?
[marto]: good morning all
[Corion]: Hi marto!
[Corion]: The fun show at $work continues, as The Big Project is now in its second week of frantic live-bugfixing and weekend releases where nobody knows what went live. Nothing has been tested anyway.
erix mutters cantankerously under his breath
Corion watches from the sidelines. Or rather, from behind, as my system only gets output from that process and my programs adhere strictly to the GIGO design principle.
[erix]: ah, that's nice to hear Corion :)
[Corion]: erix: Yeah, the sad thing is that all I can do is document things, so I can point fingers when the auditors come :-/
[Corion]: "I'm here to open tickets and point fingers. And I'm all out of tickets."
[erix]: didn't Sybase have pretty good auditing? :) (this is a vague memory)
[erix]: (culprits often are upstream of db of course)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-03-28 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (328 votes). Check out past polls.