people seem to have missed the rather idiomatic:

while(my $data = <>){ process the line of data }

<> in a while like this is a special case, and will automatically open any files listed on the command line, or read from standard input. You should be able to save out $processfilename=$ARGV[0]; beforehand for use in making your $cleanfilename. Using this construct saves you from needing to manually open and close the file.

Using my where you first use your variables is more readable than "declaring" them beforehand. This is one of the shortcomings of C, that every language since seems to have gone out of their way to overcome.

A little indentation would also make your code a little easier to parse visually :-)

Oh, and you might not want to unconditionally decrement $datalengthtrack after a chomp(). Chomp doesn't always remove characters, so depending on the input dataset, you might get errors. It DOES however return the number of chars removed, so you can capture that info and use it ($datalengthtrack -= chomp($data); or the like)


In reply to Re: New Perl User Question by edebill
in thread New Perl User Question by Rpick

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.