a4udi
02-22-2005, 04:20 PM
I'm trying to modify an alternate version of formmail below.
currently it spits out results as follows:
"S1_First_Name" ============> "sdfsdf"
"S1_Last_Name" ============> "sdfsd"
"S1_Address" ============> "sdfsd"
Is there any way to clean this up or at least to Bold the results?
ex.
"S1_First_Name" ==========> "sdfsdf"
"S1_Last_Name" ==========> "sdfsd"
"S1_Address" ============> "sdfsd"
$message = $email_format;
# make all necessary variable exchanges
while($message =~ m/<\$([0-9]|[a-z]|[A-Z]|_|\-|!>)+>/gc) {
my $var = $&;
$var =~ s/^(<\$)|>$//g;
my $val = '['.$var.' - undefined]';
# firstly, is it an internal variable?
if($var eq 'senttime') {
$val = &senttime;
} elsif ($var eq 'all_vars') {
$val = '';
my $key;
foreach $key (@params) { $val .= "\"$key\" ============> \"".param($key)."\"\n"; }
} else {
# the variable is POST or GET, swap it
if(defined param($var)) {
$val = param($var);
} else {
# hrm, is it an environment variable?
if(defined $ENV{$var}) {
# yup, make the change
$val = $ENV{$var};
} else {
# is it a cookie?
if(defined cookie($var)) {
# yay
$val = cookie($var);
}
}
}
}
$message =~ s/<\$$var>/$val/g;
}
$message =~ s/\n/\r\n/g;
currently it spits out results as follows:
"S1_First_Name" ============> "sdfsdf"
"S1_Last_Name" ============> "sdfsd"
"S1_Address" ============> "sdfsd"
Is there any way to clean this up or at least to Bold the results?
ex.
"S1_First_Name" ==========> "sdfsdf"
"S1_Last_Name" ==========> "sdfsd"
"S1_Address" ============> "sdfsd"
$message = $email_format;
# make all necessary variable exchanges
while($message =~ m/<\$([0-9]|[a-z]|[A-Z]|_|\-|!>)+>/gc) {
my $var = $&;
$var =~ s/^(<\$)|>$//g;
my $val = '['.$var.' - undefined]';
# firstly, is it an internal variable?
if($var eq 'senttime') {
$val = &senttime;
} elsif ($var eq 'all_vars') {
$val = '';
my $key;
foreach $key (@params) { $val .= "\"$key\" ============> \"".param($key)."\"\n"; }
} else {
# the variable is POST or GET, swap it
if(defined param($var)) {
$val = param($var);
} else {
# hrm, is it an environment variable?
if(defined $ENV{$var}) {
# yup, make the change
$val = $ENV{$var};
} else {
# is it a cookie?
if(defined cookie($var)) {
# yay
$val = cookie($var);
}
}
}
}
$message =~ s/<\$$var>/$val/g;
}
$message =~ s/\n/\r\n/g;