I I'm trying to make a big phone book so I've made a script that write the name and the phone number to a data base. it write the name and the phone number like this:
name!phonenumber
(ex:
Nathalie!450-267-3390,
Caroline!450-234-2938,
etc...)
then I have to make a script that give the number to someone else requesting for it . SO I wrote :
#!/usr/bin/perl
########################
#readung the form input#
########################
read(STDIN, $forminput, $ENV{'CONTENT_LENGTH'});
$forminput =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$forminput =~ tr/+/ /;
####################
# reading data file#
####################
open (INFILE, "tel.txt");
@infile = <INFILE>;
close INFILE;
#######################################
#Splitting the @infile into two scalar#
#######################################
@splited = $infile =~ tr/!/,/;
##########################################
#Starting the loops to find the good user#
##########################################
while (@infile){
if ($splited[$i] eq $forminput) {
print "$infile[$i]\n";
}
else ($i){
$i++
}
}
# the else is supposed to increment the array[number]...
#############################
#Printing html header codes #
#############################
print "Content-type:text/html\n\n";
print "<html><head><title>numéro de téléphone</title></head><body>";
#print "@infile\n"; # just a test
#print "$forminput\n"; # just a test
#print "$splited[0] et $splited[1]\n"; # just a test
print "</body></html>";
so how I should really write those codes to do what I need !?
Thanks and have fun...
name!phonenumber
(ex:
Nathalie!450-267-3390,
Caroline!450-234-2938,
etc...)
then I have to make a script that give the number to someone else requesting for it . SO I wrote :
#!/usr/bin/perl
########################
#readung the form input#
########################
read(STDIN, $forminput, $ENV{'CONTENT_LENGTH'});
$forminput =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$forminput =~ tr/+/ /;
####################
# reading data file#
####################
open (INFILE, "tel.txt");
@infile = <INFILE>;
close INFILE;
#######################################
#Splitting the @infile into two scalar#
#######################################
@splited = $infile =~ tr/!/,/;
##########################################
#Starting the loops to find the good user#
##########################################
while (@infile){
if ($splited[$i] eq $forminput) {
print "$infile[$i]\n";
}
else ($i){
$i++
}
}
# the else is supposed to increment the array[number]...
#############################
#Printing html header codes #
#############################
print "Content-type:text/html\n\n";
print "<html><head><title>numéro de téléphone</title></head><body>";
#print "@infile\n"; # just a test
#print "$forminput\n"; # just a test
#print "$splited[0] et $splited[1]\n"; # just a test
print "</body></html>";
so how I should really write those codes to do what I need !?
Thanks and have fun...