Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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]
[vrk]: Hope he gets better soon.
[Discipulus]: hdb sorry i profit; is known that a prime number is never a figurate one nor the sumattion of two adjacent figurates of the same order? like 3th triangular+3th tetrahedric
[Discipulus]: if known where i can read about the matter?
[choroba]: he's not really sick, we just got nobody to look after him today
[Discipulus]: create an account for him; we are funny baby sitters ;=) come here child, want to listen the typeglob tale?
[vrk]: choroba Oh, that's good.
[vrk]: Discipulus I don't know much about prime numbers, but wouldn't that kind of an answer be in a graduate-level number theory book?
[Discipulus]: my 8 yo daughter has two weeks of sleep disturbs.. we are gonna be crazy..

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-04-27 07:59 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (501 votes). Check out past polls.