<?xml version="1.0" encoding="windows-1252"?>
<node id="634455" title="Re: in memory files in 5.6.1" created="2007-08-22 14:02:31" updated="2007-08-22 10:02:31">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
Helpful use: in this example i wanted to open an in-memory file so i could make use of Perl's: format &amp; write operations.  This will print a formatted line into a "in mem" file and return it as a scalar string to the calling function.  It was a easy way of making a formatted (aligned) toString() for my class.  Enjoy. 
&lt;p&gt;
&lt;code&gt;
sub toString
    {
       my $self = shift;
       my $thishash = $self-&gt;{_listofkeys};
       my $memfile;
       open (FORMATTED_OUT, '&gt;',\$memfile) || warn "unable to open memory file!";

format FORMATTED_OUT =
        IMEI              BrandName            Model             OS                  Registered To
        ==========================================================================================================
        @&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; @&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; @&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; @&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; @&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
        $thishash-&gt;{IMEI}, $thishash-&gt;{PhoneBrandName}, $thishash-&gt;{PhoneModel}, $thishash-&gt;{PhoneOS}, $thishash-&gt;{RegisteredTo}
.

    write FORMATTED_OUT ;
    close (FORMATTED_OUT);
    return  $memfile;
    }
&lt;/code&gt;</field>
<field name="root_node">
302088</field>
<field name="parent_node">
302088</field>
<field name="reputation">
1</field>
</data>
</node>
