I am trying to simplify the coding in a script I was given, but it was written 7-10 years ago and is pretty complicated. below is a tidbit, if someone can break it down for me I would appreciate it.
[highlight=perl]sub ParseText
{
my ($line, $key, $value, $sub, $script);
foreach $line \(@_\) \{
while \(\($key => $value\) = each %FORM\)
\{ $line =~ s/\\[$key\\]/$value/ig \}
while \(\($key => $value\) = each %ENV\)
\{ $line =~ s/\\[\\%$key\\]/$value/ig \}
if \($line =~ /<script/\) \{$script = 1;\}
if \($script != 1\) \{
$line =~ s/\\[[^<]\(.\)*?[^>]\\]//g;
\} else \{
$line =~ s/\([^A-Za-z0-9\\-_,]\)\\[[^<]\(.\)*?[^>]\\]/$1/g;
\}
if \($line =~ /<\\/script/\) \{$script = 0;\}
\}
foreach $line \(@_\) \{
while \($line =~ /\\[<\(\(.\)*?\)>\\]/\) \{
$sub = $1;
if \($sub !~ /^\([\\d\\\+\\\*\\/\\-%\\.,x<>\\\(\\\)\\s]|round|ifcond\)*$/s\) \{
\#Error\("Error in expression", $sub\);
\}
$sub = eval $sub;
$line =~ s/\\[<\(.\)*?>\\]/$sub/s;
\}
\}
return @_;
}
sub ParseTextMail
{
my ($line, $key, $value, $sub, $script);
foreach $line \(@_\) \{
while \(\($key => $value\) = each %FORM\)
\{
$value =~ s/\\n/\\<br\\>/g;
$line =~ s/\\[$key\\]/$value/ig
\}
while \(\($key => $value\) = each %ENV\)
\{ $line =~ s/\\[\\%$key\\]/$value/ig \}
$line =~ s/\\x7e\(\\w\+\)\(\(\\[\)\(\\d\)\(\\]\)\)?/eval "\\$$1$3$4$5"/e;
\}
return @_;
}[/highlight]