Re: inputting the ephemerides

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Quoted text here. Click to load it

    my $first7 = substr $line, 0, 7;

Quoted text here. Click to load it

If you want to validate the data against those criteria, then:

    die "'$first7' is 'bad' data\n" unless $first7 =~ /^[a-z]+\s*$/i;

Quoted text here. Click to load it

Errr... OK:

    $first7 = '';

If you instead meant to say "strip away all the trailing space characters":

    $first7 =~ s/\s+$//;

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Re: inputting the ephemerides

Quoted text here. Click to load it

Maybe you meant 'strip away all of the non numeric characters'.
$first7 =~ s/\D//g;
That will also take out any periods and negative signs which you might
want so you might have to tailor the expression a bit more than that.

Perhaps you could split the lines of the input file into fields and
then write some conditional logic which might do different
substitutions based on what expression the data matches before you
populate your objects.

$field =~ s/\s//g;
if ( $field =~ /\d+\./ ) {
} elsif { $field =~ /^*\d+\D/ ) {



A really "great way to continue exploring perl's pattern-matching
capabilities" might be to go to

or type

perldoc perlre <enter>

or read your textbook more closely maybe?

Good luck,

Site Timeline