Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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......

In reply to Lo, for i am blind by jcpunk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (None)
    As of 2024-04-25 04:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found