People generally do

use strict; use warnings;

nowadays, and that's the single best piece of advice I can give you!

Also, people do

my @DATA=<ORIGFILE>;

but then they also prefer to avoid slurping in files all at once, and they iterate on the lines instead with a while loop rather than with a for one:

while (my $line=<ORIGFILE>) { # ...

In any case you have to specify '>' mode in open for writing (and '>>' for appending). More generally I recommend you to stick with the three args form of open and lexical handles, and always check the return value:

open my $in, '<', "whatever" or die "can't open `whatever': $!\n"; open my $out, '>', "whatever" or die "can't open `whatever': $!\n";

In reply to Re^3: Seperating individual lines of a file by blazar
in thread Seperating individual lines of a file by tgrossner

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.