Stupid Script -HELP!
This is NOT my day for perl. I am writing a script that lets you e-mail users. Take a look:
#Mail to ##################################
} elsif ($action eq "mailto") {
$user = $form{'user'};
{&header;}{&decodenames;}
print qq|
$user
Contacting $userb, $recipient
Name:
Age:
Location:
E-Mail:
Reason for Contact:
Reasons..
Site Problem
Hosting
Just for the Heck of it
Other
Comments:
|;
{&footer;}
#Send the mail! #########################
} elsif ($action eq "returnmail") {
$user = $form{'user'};
{&header;}{&decodenames;}
print qq|
E-mail was sent to $userb!
|;
{&footer;}
$mailprog = "/usr/sbin/sendmail";
open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
print MAIL "Reply-to: $FORM{'email'}\n";
print MAIL "From: $FORM{'name'}\n";
print MAIL "Subject: $FORM{'prob'}\n";
print MAIL "Age: $FORM{'age'}\n";
print MAIL "Location: $FORM{'ocation'}\n";
print MAIL "Comments: $FORM{'comments'}";
close(MAIL);
}
--->Sub from script:
sub decodenames {
if ($user eq "laguna") {
$userb="Laguna Loire";
$recipient="laguna\@3dstream.net";
} elsif ($user eq "talon") {
$userb="Talon Raines";
$recipient="talon\@3dstream.net";
} elsif ($user eq "trepegroupie") {
$userb="Trepe Groupie";
$recipient="groupie_of_trepe\@yahoo.com";
} elsif ($user eq "azn") {
$userb="Azn Dragon";
$recipient="Azn_Dragon\@shinra.org";
}
}
The problem is that the server wont decode the $form('something') for some dang reason. Do you guys see what I mean?
Laguna Loire
Site Director: Laguna's Jukebox (http://jukebox.3dstream.net)
Site Admin: RPGBoards (http://rpgboards.3dstream.net)
richjb posted this at 05:39 — 6th August 2000.
They have: 193 posts
Joined: Feb 2000
Look at the bolded info below:
[edit]Forgot to end quote[/edit]
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
Laguna Loire posted this at 15:17 — 6th August 2000.
They have: 45 posts
Joined: Aug 2000
1. I put them in subs. because the program calls on them several times, not just once. I want to be able to edit the html and other things for each section without having to change it in each section.
2. I guess I did! Thanks!
Laguna Loire
Site Director: Laguna's Jukebox (http://jukebox.3dstream.net)
Site Admin: RPGBoards (http://rpgboards.3dstream.net)
richjb posted this at 18:02 — 6th August 2000.
They have: 193 posts
Joined: Feb 2000
I meant why do you embed the subroutine calls, I know why you put them in subs; I did not ask correctly.
Richard
Laguna Loire posted this at 20:29 — 6th August 2000.
They have: 45 posts
Joined: Aug 2000
What exactly do you mean? (sorry, im still a little new at perl)
richjb posted this at 23:26 — 6th August 2000.
They have: 193 posts
Joined: Feb 2000
This is a call to a subroutine:
&my_sub;
This is a call to an embeded subroutine:
{&my_sub;}
Oh well, your way works, but I don't see why you pick that style.
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
Laguna Loire posted this at 03:55 — 7th August 2000.
They have: 45 posts
Joined: Aug 2000
Oh really! I didnt know that. Does it really matter?
richjb posted this at 04:39 — 7th August 2000.
They have: 193 posts
Joined: Feb 2000
It shouldn't matter. Before looking at that code I had never seen that done. However, after research, I have discovered that it could make a difference, but not likely. It would only make a difference if certain commands are made, which you aren't and won't be making.
For more information on the above:
http://www.perl.com/pub/doc/manual/html/pod/perlsub.html
Also, usually the { } tags show a set of something, it can be used for visualizing the difference between
{
this...
}
and...
{
that...
}
I just find it weird. Not a bad habbit; may make your code easier to read by grouping commands together. Other than that, I see it as vanity.
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.