Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

How do I read from one file and write my processed results to another file?

by Zombie sandmuto
on Oct 15, 2001 at 14:33 UTC ( #118844=categorized question: print w/replies, xml ) Need Help??
Contributed by Zombie sandmuto on Oct 15, 2001 at 14:33 UTC
Q&A  > files


I have written code that accepts input from one file named pa1.dat. It checks whether the input is accepted by a certain finite automaton. If it is, then it is supposed to output the results in another file named pa1.out. The problem is that after compling successfully without any errors, the pa1.out file doesn't contain anything. Would you please tell me the correct syntax on how to get the data from one file and direct output to another file?

Answer: what statements are used in order to obtain results in another file?
contributed by davorg

This is still the Finite Automata problem from the University of Zimbabwe isn't it?

In order to read or write from a file, you need to first open a filehandle. Here's a link to the documentation on open.

You output data to a file using the print function. Documentation on print is here.

If you have any further questions, perhaps you could show us the code - we'd then be able to be more help.

Please (register and) log in if you wish to add an answer

  • 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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2021-02-28 16:40 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found