Page 1 of 1

email email email

Posted: Wed Aug 03, 2005 6:41 am
by samip1983
Hi all,

was jus playing with some code i need to manipulate email address, this is just the beginning part. I need once the email is entered a switch is also used. U means upper case. WC means for all the . to be changed to / dot / and the @ changed to / at /.
The next switch is wc and does the reverse of the WC switch. This doesnt seem to work at all. and its buggin me.

Code: Select all

#!/usr/bin/perl
use strict;
use CGI ':standard';

my ($email, $switch, $up);

$email = param('email');
$switch = param('switch');

$up = uc($email);

print "content-type: text/html\n\n";

if (($email) && ($switch =~/U/)) {
print "$up\n";
}

elsif (($email =~ s/\./ dot /g) && ($email =~ s/\@/ at /g) && ($switch =~ /WC/)) {
print "$email\n";
}

elsif (($email =~ s/ dot /\./g) && ($email =~ s/ at /\@/g) && ($switch =~/wc/)) {
print "$email\n";
}
Any help would be great

Thanks

Sami P

d11wtq | fixed U ==> U ;)

Posted: Wed Aug 03, 2005 9:23 am
by Chris Corbyn
I haven't tested but this should work. You should stop using regex to check for a static string (the regex were validating something like "UUUGGAFAGSH" as if it was "U"...)

Code: Select all

#!/usr/bin/perl
use strict;
use CGI ':standard';

my ($email, $switch, $up);

$email = param('email');
$switch = param('switch');

$up = uc($email);

print "content-type: text/html\n\n";

if ($email && $switch eq "U") {
print "$up\n";
}

elsif (($email =~ s/\./ dot /g) && ($email =~ s/\@/ at /g) && $switch eq "WC") {
print "$email\n";
}

elsif (($email =~ s/ dot /\./g) && ($email =~ s/ at /\@/g) && $switch eq "wc") {
print "$email\n";
}

Posted: Wed Aug 03, 2005 2:49 pm
by samip1983
Hi,

thnaks for your reply.

Some of the code works fine, the bit that doesnt work is if the $email is for example 'x dot x at hotmail dot com', the wc switch does not seem to be changing the email to 'x.x@hotmail.com', cant seem to put my finger on the problem.
My initail thought is the space in the regex, becase when entering U as a switch and the $email is 'x dot x at hot.......' the result is just a 'X'

Any ideas??

thanks