Antonio Jose wrote:

> Hello.... I have 3 weeks learning Perl and I am trying to solve a
> trouble
> I need to write my thesis....

Learn Perl first, then try to apply it to complex mathematical issues.

>
>
> I have to read a file where I don't know the content of the first rows
> (only strings) and I need to read only data (numbers), I mean, I am
> going

Huh?  Do you mean that the first line contains column names, and the rest
numerical data.  That should not be a big problem   Unfortunately, we can
offer little help, because you have not told us how the lines are delimited.



> to read information that begin with blank spaces and numbers, from
> there,
> I have a matrix of 7 columns and n rows (I don't know the exact numbers
> of rows), the column 1 correspond to depth and the next 6 columns
> correspond to variables in each depth.

[snipped because we don't have the starting context yet.]

I looked at your script, and here are some suggestions:

use strict;
use warnings;

These are essential to not wasting your time when programming Perl.  Until
they are in place, your scripting efforts are wasted.

Use subroutines for everything.  Your script had almost 100 lines of
incomprehesible scripting garbage before the first subroutine definition.
Below is the total content, outside of subroutine definitions, of my most
recent Perl program--almost 600 lines in all:

#!perl -w

use strict;
use warnings;

use Tk;

use constant SOURCE => 'Perl Beginners';
use constant MESSAGE_DB => 'dbm/messages.ndb';
use constant SKIP_FILE => 'dbm/skipfile.ndb';
use constant SKIP_SIZE => 100;

our @month_lengths = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

{
  if (@ARGV and $ARGV[0] eq 'parse') {
    parse_mailbox();
    create_message_indices();
  } else {
    lauch_viewer();
  }
}

The program works beatifiully. Well, the first branch does.  The else branch
is under construction.  No problem, since the else branch is properly
encapulated.   There is not a single function definition in this that can
not be viewed, in totality, in a single 23 row x 70 column screen.  It is a
dream to work with.

To get there, you have to learn to break up your stream of consciousness
into manageable chunks.  I can't do that for you, nor can anyone else.

I would suggest that you start with some more modest projects.  Focus on:

Encapsulating processes in subroutines.
Passing information into those subroutines using parameters.
Using references and using return values to get information back out of the
subroutines.
Getting a comprehensive understanding of scoping.

I can see only confusion and frustration ahead for you if you try to move
into advanced processing without developing the basic skills that make
programming easy.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to