In your first snippet, one problem could be where "$storyfile" comes from. Is a portion of it coming from a source that taint mode would frown upon? That's my thought; that you'e accepting at least a portion of $storyfile from a source that could be considered tainted (or taintable).

In your second snippet, you're not even opening the file for output; you're opening it for input. And "Could not write..." is fooling you; it's your own error message. It should actually say, "Could not read from..." (since you're opening the file for reading in that second snippet). And the reason it's failing to open for reading is probably that it doesn't exist yet since you haven't written it yet.

By the way; use the three-arg version of open: open STORY, '>', $storyfile or die .....

Oh, that reminds me of another problem; in your first snippet you're using the wrong "or"; since there aren't any parens around the open argument list, you need to use "or" instead of "||", or else you get into precedence trouble.


Dave


In reply to Re: Having trouble creating a text file by davido
in thread Having trouble creating a text file by greymoose

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.