Hi,
I'm relatively new to perl, so my code is a little rough around the edges. I'm trying to create an alumni 'database' for my school and I got my form to send the variables to a perl script, but for some reason, I can't get my script to write the variables to a file...I created a function called writeFile that takes all the variables (right now it's only 1) I want to write. I've tried all kinds of variations on the open ... syntax, but to no avail...does anyone have any idea of what i'm doing wrong?
sub writeFile {
$data_file = "alum2.txt";
open ALUM2, ">>$data_file" or die "cannot open $data_file $!";
flock (ALUM2, 2) || Error('lock', 'file');
print ALUM2 "$_[0]";
close (ALUM2);
}
I'm relatively new to perl, so my code is a little rough around the edges. I'm trying to create an alumni 'database' for my school and I got my form to send the variables to a perl script, but for some reason, I can't get my script to write the variables to a file...I created a function called writeFile that takes all the variables (right now it's only 1) I want to write. I've tried all kinds of variations on the open ... syntax, but to no avail...does anyone have any idea of what i'm doing wrong?
sub writeFile {
$data_file = "alum2.txt";
open ALUM2, ">>$data_file" or die "cannot open $data_file $!";
flock (ALUM2, 2) || Error('lock', 'file');
print ALUM2 "$_[0]";
close (ALUM2);
}