You need to specify a 'mode' when you use open. This means that you specify whether you want to read from or write to a particular file (you can do both, but you don't need that for now).
open($INPUT, "<", "my_input_file.txt"); #the "<" tells it you want to
+read from the file
open($OUTPUT, ">" "my_output_file.txt"); #the ">" tells it you want to
+ write to the file.
#.. do some changes to $line ..
print $OUTPUT $line #prints $line (after I've done whatever chang
+es) to the file I opened as $OUTPUT
check out here for some more info on filehandles. Also bear in mind that you can either not declare a filehandle, and just use a plain text word, e.g. open(INPUT,"<","input_file.txt); or you can declare a variable as I did in the example above. IMO it's a better habit to get into to use a variable, as you start to get into trouble when/if you try to pass filehandles around subs (later..!)
hope this helps.
Those are my principles. If you don't like them I have others.
-- Groucho Marx
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.