I'm trying to make a CGI that will allow users to identify who is at what phone extension when. I need to list all extension numbers (100 - 148), and allow users to click an extension and add their name. If they are already in, and click it again then it removes their names. I'm fairly new with hashes and I think this is where I'm getting stuck. Any help or other suggested methods would be greatly appreciated.
Even a push in the right direction would be of great help right now. Thanks again for any help!
X
Code:
#!perl
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
$query = new CGI;
print $query->header;
print $query->start_html("Extensions");
print "<H1> Extensions</H1>\n";
&print_prompt($query);
&do_work($query);
&print_tail;
print $query->end_html;
sub print_prompt {
my($query) = @_;
my %extensions = (
100 => "Mike Jones",
101 => "",
102 => "",
103 => "",
104 => "",
105 => "",
106 => "",
107 => "",
108 => "",
109 => "",
110 => "",
111 => "",
112 => "",
113 => "",
114 => "",
115 => "",
116 => "",
117 => "",
118 => "",
119 => "",
120 => "",
121 => "",
122 => "",
123 => "",
124 => "",
125 => "",
126 => "",
127 => "",
128 => "",
129 => "",
130 => "",
131 => "",
132 => "",
133 => "",
134 => "",
135 => "",
136 => "",
137 => "",
138 => "",
139 => "",
140 => "",
141 => "",
142 => "",
143 => "",
144 => "",
145 => "",
146 => "",
147 => "",
148 => "",
);
my $key;
my $extensions;
print $query->start_form;
print $query->textfield('name');
foreach $key ( 100 .. 148)
{
print $query->submit('Action',"$key:$extensions{$key}");
}
print $query->endform;
print "<HR>\n";
}
sub do_work {
my($query) = @_;
my(@values,$key);
print "<H2>Here are the current settings in this form</H2>";
foreach $key ($query->param) {
print "<STRONG>$key</STRONG> -> ";
my $ls = $query->param($key);
my @want = split(/:/, $ls);
print "@want[0], @want[1]";
#THIS IS WHERE I'M STUCK, I DON'T KNOW HOW TO #MODIFY/CHANGE THE HASH
}
}
sub print_tail {
print <<END;
<HR>
END
;
}
Even a push in the right direction would be of great help right now. Thanks again for any help!
X