[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] An odd error message...



Greetings:
I am new to Perl, and fear that this may be a very elementary question,
I hope that you'll bear with me...
I have been working on the following code (the goal of which is
ultimately to consult a database, and determine the number of items
which need to be reordered):


#!/usr/bin/perl -w
use strict;

my $dbase = 'stock.dat';
my $report = 'restock.txt';
my $order;

open (DBASE, $dbase) || die "can't open $dbase: $!";
open (REPORT, ">$report") || die "can't open $report: $!";


while ( <DBASE> ) {
    chomp;

    my @fields = split;
    next if $fields[3] < 15 and $fields[2] >= 50;
    next if $fields[3] >= 15 and $fields[2] >=20;



    if ($fields[2] < 50 and $fields[3] <= 15){
        $order = "more of these";


    }

    print REPORT "$fields[0] : $fields[1]\n";
    print REPORT "\torder: $order\n";


}
close DBASE;
close REPORT;
__END__

with this Data Base:

123 widget 3 17.00
214 gadget 8 15.50
313 thingamabob 27 0.2
222 foo 9 2.00
133 a_nut 11 25.00
144 b_nut 29 22.00
211 c_nut 55 5.00

And I am getting variations on the following error message:

# Use of uninitialized value, <DBASE> chunk 1.
File 'Macintosh HD:MacPerl ƒ:MacPerl Scripts:reorder_b.pl'; Line 28
# Use of uninitialized value, <DBASE> chunk 2.
File 'Macintosh HD:MacPerl ƒ:MacPerl Scripts:reorder_b.pl'; Line 28

I understand from a mentor that this works on other platforms;
therefore, either I'm making a coding error that I can't see, or I'm
coming up against something specific to MacPerl...

Apologies for the length of this; I wanted to be complete...
Many Thanks...
ARGoldman



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org