D'day all,
I have the following chunk of code that I was wondering If I can write a
little smaller. I was thinking a while loop. Could some one give me a
little advice on this one :)...
results_read();
if ($poll =~ /newspaper/) {
print "Thank you for picking news paper!";
$nonewspaper = $filehash{$title}{"Newspaper"};
$new_newspaper_total = $nonewspaper + 1;
$filehash{$title}{'Newspaper'} = $new_newspaper_total;
write_results($poll_file, $filehash);
} elsif ($poll =~ /wordofmouth/) {
$no_wordofmouth = $filehash{$title}{'Word of mouth'};
$new_no_wordofmouth = $no_wordofmouth + 1;
$filehash{$title}{'Word of mouth'} = $new_no_wordofmouth;
write_results($poll_file, $filehash);
} elsif ($poll =~ /friend/) {
$no_friend = $filehash{$title}{'Friend'};
$new_no_friend = $no_friend + 1;
$filehash{$title}{'Friend'} = $new_no_friend;
write_results($poll_file, $filehash);
} else {
# Theoretically there shold never be a non match as we are using
radio
# buttons!
print "No Match!";
}
results_read();
It's pretty straight foward... Basically if $poll matches what I have
told it to match then we it goes and writes some results to a file. I
have a tingling feeling that I would be better off using a whilt loop.
I just don't know where to start.
Kind regards,
Dan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]