Suggestions.
Don't use a variable called $newvar, call it $form_input or $phone_number or
somthing. Make it descriptive of the value it holds, either the source of
the data or the expected content. It'll make life easier in the long run.
Use a module to inferface with Sendmail. Let it do the hard work of
formatting and interfacing with sendmail, that's what it's there for.
http://www.tneoh.zoneit.com/perl/SendMail/
Where's the code that accepts the input from the form? How are you passing
that data, via POST or GET?
Why use a substr to strip the leading 0? What if there is no leading 0? Try
---
$phone_number = "012345012345";
print "$phone_number\n";
# Next line is all you need
$phone_number =~ s/^0//;
print $phone_number;
---
This strips only a 0, only one of them and only if it's at the very start of
the string.
John
-----Original Message-----
From: Euan [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 15:54
To: [EMAIL PROTECTED]
Subject: Please help me!
I have been trying to write a script .
a mobile number is entered into a form which is sent to the script,
The script removes the leading 0 then
adds a +44 in front and
tacks a @domain.com onto the end.
Then it saves this new number/email to a txt file and automatically sends
out
an e-mail to the +44 (some number)@domain.com e-mail address.
Here is as far as i have got.. Any ideas or help appreciated.
#!/usr/bin/perl -w
$newvar = substr($variable, offset);
$newvar = "+44" . $variable . "\@domain.com";
unless (open(MAIL, "|/path/to/sendmail -t")) {
die(" Failed to talk to sendmail\n");}
print MAIL <<"MAIL1";
To: $recipient
From: $sender
Subject: $subject
$message
MAIL1
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.