i tried it with hashes I am probably not even using them right and I probably have to put $votes{name} for every candidate in the script by $vote{sam}

#!/usr/bin/perl use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; $prez=param('prez'); $vice=param('vice'); $secretary=param('secretary'); $count = 1; my %votes; my $file = 'vote.txt'; open my $ih, $file or die $! while (<$ih>) { chomp; my ($user, $count) = split ','; $votes{$user} = $count; } close + $ih; $votes{sam}++; open my $oh, $file or die $! for my $user (keys +%votes) { print $oh "$user,$votes{$user}\n"; } close $oh; print "<a href=www.smccme.edu>main page</a>";

it spat out a bunch of syntax errors , and since i don't understand the syntax used with hashes I don't really see the problems. I think I am going to stick with what I know because I need to re-write this whole script from memory during class for the final. even if I get the hashes to work I doubt I could remember it all and understand what it all does by monday.it is just frustrating to have one last thing to do on this script after two weeks of working on it and be so close I'm going to try to figure out why the text file is changing it self around thanks for the help.


In reply to Re^4: incrementing array variables in a text file? by friar tux
in thread incrementing array variables in a text file? by friar tux

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.