Re: Fields won't add when reading a text file
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Sun, 30 Apr 2006 03:55:02 +0200
NevadaSam@xxxxxxxxx wrote:
This is the script I have been working on all day and the text file which it reads follows it.
<script and data snipped>
These are a few hints:
The numbers represent which seminar by 1-Computer Maintenance, 2-Microsoft Office, 3-Unix Essentials, and 4-CGI/Perl.
You need to tell Perl that, too. This is one way to do so:
my %translate = (
1 => 'Computer Maintenance',
2 => 'Microsoft Office',
3 => 'Unix Essentials',
4 => 'CGI/Perl',
);
And in the loop:
$sem_count{ $translate{$seminar} } ++;
As regards the number of names/records, you can just use the @records array in scalar context:
print "<br /><br />Total registered: " . @records . "\n";
Your use of a @name_count array is incorrect, and generates a bunch of warnings if warnings are enabled (which should be the case...).
Warnings may give you a couple of other hints.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- Fields won't add when reading a text file
- From: NevadaSam
- Fields won't add when reading a text file
- Prev by Date: Re: FAQ 4.41 How can I remove duplicate elements from a list or array?
- Next by Date: Re: Fields won't add when reading a text file
- Previous by thread: Fields won't add when reading a text file
- Next by thread: Re: Fields won't add when reading a text file
- Index(es):
Relevant Pages
|