Hi fellow Monks,

Before I say anything I should say i'm pretty new to Perl, so sorry if this is a stupid question:-)

I wrote a message a little earlier about writing a normal perl array to disk, in the same way as the old dbmhash thing did for hashes. I got messages back telling me about tie() and storage.pm and i've looked at these all afternoon, but even after reading loadsa man pages and tutorials I just can't get anything to work. I'm using Activestate perl and it just complains about wrong versions when I try using storage.pm and I don't know anything about creating packages for the tie() thing.

I'm developing a web spider, at the moment my program keeps the list of URLs to visit in an array. I would simply like to store these values on disk so if my spider crashes I don't loose my list of URLs to visit, and I can carry on where my robot left off.

Any idea what the best way of doing this is? I could just keeping opening and closing file handles and writing to a normal text file, but that seems a bit slow and dodgy to me. I thought about using the dbmhash thing, but I know that's deprecated. Anyway, any code examples would be really appreciated.

Many thanks once again, Tom


In reply to Writing Arrays to disk by shaolin_gungfu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.