On a note quite similar to mikfire's The Clue by Four, and the excellent Before You Post ... by Ovid, I wanted to share the strugle of my last hour with you.

I am writting a recursive function that opens a file, but I couldn't remember how to localize a filehandle. So I started to write a detailed explanation of the problem when an idea struck me... I could kludge my way around this. That was a bad idea. The kludge worked, but it was both slow and ugly, so I starting trying to write my SOPW post again. But then, while staring at the title of that post, I realized that I hadn't looked in the index of my favorite perl reference for filehandles, localizing which I quickly did and found that on page 51 was the solution. A quick addition of one line (and the removal of the kludge) and my code was back up to speed and functional.

The moral of the story is that the more thought you put into a post, the more likely you are to figure out the answer yourself. And of course, simple things are usually simple, at least in perl.

By the way, "local *MYFILEHANDLE;" is how you localize a filehandle.


In reply to Localizing Filehandles by Adam

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.