i am getting the following error and have no idea why
syntax error at ./vacation.pl line 33, near ")
&"
syntax error at ./vacation.pl line 38, near "}"
Execution of ./vacation.pl aborted due to compilation errors.
there is obviously a simple reason for this error that i just cannot find.....
the code for the script is below
#!/usr/local/bin/perl -w
use strict;
#declare vars
our $set_fwd;
our $username;
our $message;
our $on_off;
our $FILENAME;
our @list_of_files;
#initialize @list_of_files to what the correct list of files
@list_of_files=(".forward", ".vacation.msg", ".vacation.pag", ".vacati
+on.dir");
`touch Adfasfasfasdfasdfhlasfhasdfhdsfjhjdhsfhfajfhjfhasjfh`;
###
# pass arguments in this patern: username on/off message no quotation
+s needed
###
if (($#ARGV > 1) || (($#ARGV ==1) && ($ARGV[1] eq "off")))
{
$username=$ARGV[0];
$on_off=$ARGV[1];
if($on_off eq "on")
{
$message = join (" ",@ARGV);
$message =~ s/$username//;
$message =~ s/$on_off//;
&On();
}
elsif ($on_off eq "off")
&Off();
else
{
print "Necessary Value Contains Incorrect Parameters\n";
exit 1;
}
}
else
{
print "Error Reading Action\n";
exit 1;
}
print " <div align=\"center\"> $username\'s vacation message has been
+ \n";
print " <font color=red>";
if($on_off eq "on")
print "Activated";
else
print "Deactivated";
print " </font>.</div><BR>\n";
print " <div align=\"center\">\n";
print " </div>\n";
print " <center><BR>Please E-Mail <a href=\"mailto:$username\@iwu
+.edu\">$username\@iwu.edu</a>\n";
print " to test this message. <BR> If you ";
if($on_off eq "on")
print "do not ";
print "recieve an automatic response with your\n";
print " vacation message please resubmit this form</center>\n";
}
else
print "<b>Not all necessary values have been given.</b>\n";
sub On
{
foreach $FILENAME (@list_of_files)
{
open(TempFile, ">/home/$username/$FILENAME") || die ("Unable to op
+en /home/$username/$FILENAME");
if ( $FILENAME eq ".forward")
{
#.forward must look like
#\username, "|/usr/bin/vacation username"
$set_fwd="\\$username, \"|/usr/bin/vacation $username\"";
print TempFile $set_fwd;
}
if ( $FILENAME eq ".vacation.msg")
{
print TempFile $message;
print TempFile "\n";
}
close(TempFile);
`chmod 644 /home/$username/$FILENAME`;
`chown $username /home/$username/$FILENAME`;
}
}
sub Off
{
foreach $FILENAME (@list_of_files)
`rm -f /home/$username/$FILENAME`;
}
Can anyone put a second set of eyes on this for me? and possibly offer optimization suggestions......