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

Re: Problem with Data Extraction

by Athanasius (Prior)
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


Comment on Re: Problem with Data Extraction
Select or Download Code
Re^2: Problem with Data Extraction
by jpvinny28 (Initiate) on Dec 05, 2012 at 17:07 UTC
    Thank You for the advice.. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006992]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2014-07-13 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (248 votes), past polls