Stamp_Guy has asked for the wisdom of the Perl Monks concerning the following question:
614 MNH,16.00|USED,32.00|PB,50.00 615 MNH,36.00|USED,12.00|PB,50.00 616 MNH,96.00|USED,2.00|PB,10.00
The code I am using to do so is as follows:
#!/usr/bin/perl -w use strict; my (@record, @details, @item, $detail, $scottnum, $details, %items); open(DB, "db.txt") || die "Could not open the database: $!"; while(<DB>) { chomp; @record = split(/\t/); $scottnum = $record[0]; @details = split(/\|/, "$record[1]"); foreach $detail (@details) { @item = split(/,/, "$detail"); if (($item[0] ne "") && ($item[1] ne "")){ $items{"$item[0]"} = "$item[1]"; foreach my $key (%items) { print "$scottnum\t $key \t $items{$ +key}\n"; } } } } close(DB) || die "Could not close the database: $!";
I keep getting the error: "use of uninitialized value at parse.pl line 19, <DB> chunk 3". I get that error every other line. Could someone please explain to me what I'm doing wrong?
Stamp_Guy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stuck while learning about the hash
by dws (Chancellor) on Jun 08, 2001 at 06:58 UTC | |
by Stamp_Guy (Monk) on Jun 08, 2001 at 07:25 UTC | |
by mr.nick (Chaplain) on Jun 08, 2001 at 07:46 UTC | |
by Stamp_Guy (Monk) on Jun 08, 2001 at 08:21 UTC | |
by andreychek (Parson) on Jun 08, 2001 at 08:32 UTC | |
|
Re: Stuck while learning about the hash
by Zaxo (Archbishop) on Jun 08, 2001 at 08:42 UTC | |
|
Re: Stuck while learning about the hash
by Arguile (Hermit) on Jun 08, 2001 at 11:40 UTC | |
by Hofmator (Curate) on Jun 08, 2001 at 12:46 UTC | |
by hackmare (Pilgrim) on Jun 08, 2001 at 18:41 UTC | |
by Stamp_Guy (Monk) on Jun 09, 2001 at 07:11 UTC |