Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Problem with Data Extraction

by Athanasius (Chancellor)
on Dec 04, 2012 at 04:39 UTC ( #1006992=note: print w/replies, xml ) Need Help??

in reply to Problem while Data Extraction

Hello jpvinny28, and welcome to the Monastery!

In addition to the excellent advice given by GrandFather, above (don’t turn off warnings, avoid subroutine prototypes), here is some general coding advice that will help you in the long run:

  • Declare variables as late as possible. Your code contains a number of variables that are never used at all. Moreover, @a_str is re-written at the start of each iteration of the while loop, so it would be better to declare it at that point:

    my @a_str = split //, $line;
  • Don’t stringify numbers unless you need to (and in this case, you don’t!):

  • elsif ($count == 1) { if (...) { $count = 0; ...
  • Prefer the 3-argument form of open, and use lexical filehandles:

    open(my $INFILE, "<", $file) or die "can't open file '$file' for reading: $!";
  • Choose an indentation style, and stick to it! See perlstyle.

  • Use consistent variable names. For example, you have a filehandle OUTFILE2 opened for writing on a file named $file3. That’s a maintenance nightmare just waiting to bite you!

Hope that helps,

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^2: Problem with Data Extraction
by jpvinny28 (Initiate) on Dec 05, 2012 at 17:07 UTC
    Thank You for the advice.. :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006992]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2018-04-23 12:05 GMT
Find Nodes?
    Voting Booth?