Formatting output from shopping cart

I have a shopping cart on my company's site. It proccesses credit card data and sends the order via email to the person that takes care of that. The output is kinda sucky. How do I fix this? BTW the shopping cart is pretty complicated and I do not wnat to mess with it's code.

Typical email
The following data was entered at

 Address:    301 E Eleventyfive Street

 Address2:   301 E Eleventyfive Street

 Amount:     580.00

 City:       Wuzzleville

 City2:      Wuzzleville

 Company:    Fizzy Wizzles Whistles

 Company2:   Fizzy Wizzles Whistles

 DESCRIPTION:  Stamp Order


 LOGIN:      techinc

 Name:       Weasal Fizzlebottom

 Name2:      Weasal Fizzlebottom

 PARTNER:    bigbank

 Phone:      620-123-4567

 State:      KS

 State2:     KS

 TAX+ID:     1111222333

 TYPE:       S

 Zip:        12345

 Zip2:       12345

 comments:   None

 o01Item:    HS²Hand Stamps²Stamp Size: HS26 1.75 in diameter +$19.50³Font          : Times Roman Bold³Font Size   : Fit to Size³Signature  : Yes  +$3.00³Art Work : Yes  +$5.00³Reduce/Enlarge Art: Yes  +$2.00³Text Line 1: This is a Stamp³Text Line 2: I use it to stamp things³Text Line 3: IN FACT³Text Line 4: I just used it to³Text Line 5: Stamped this!²r;$29.50²c;11²r;$324.50

 o02Item:    NSC²Round²Stamp Size: HS28 Hand Stamp +$19.50³Name       : Weasal Fizzlebottom²r;$19.50²c;11²r;$214.50


 s02Salestax:  Sales Tax(KS)²r;$38.00

 s03Shipping:  Shipping(Out of town)²r;$3.00


Script that sends email

$mailprog= "/usr/lib/sendmail" ;
$recipient= "user\" ;      # make sure to \ escape the @

# Get the CGI input variables
%in= &getcgivars ;

# Open the mailing process
open(MAIL, "|$mailprog $recipient")
    || &HTMLdie("Couldn't send the mail (couldn't run $mailprog).") ;

# Print the header information
$ENV{'HTTP_REFERER'} || ($ENV{'HTTP_REFERER'}= "your Web site") ;
print MAIL "Subject: Form data from the Web\n\n",
           "The following data was entered at $ENV{'HTTP_REFERER'}:\n\n" ;

# Find length of longest field name, for formatting; include space for colon
$maxlength= 0 ;
foreach (keys %in) {
    $maxlength= length if length > $maxlength ;
$maxlength++ ;

# Print each CGI variable received by the script, one per line.
# This just prints the fields in alphabetical order.  To define your own
#   order, use something like
#     foreach ('firstname', 'lastname', 'phone', 'address1', ... ) {
foreach (sort keys %in) {

    # If a field has newlines, it's probably a block of text; indent it.
    if ($in{$_}=~ /\n/) {
        $in{$_}= "\n" . $in{$_} ;
        $in{$_}=~ s/\n/\n    /g ;
        $in{$_}.= "\n" ;

    # comma-separate multiple selections
    $in{$_}=~ s/\0/, /g ;

    # Print fields, aligning columns neatly
    printf MAIL "%-${maxlength}s  %s\n", "/n $_:", $in{$_} ;

# Close the process and mail the data
close(MAIL) ;

# Print an HTML response to the user
print <<EOF ;
Content-type: text/html

<h3>Your stamp order has been sent.</h3>

exit ;

#-------------- start of &getcgivars() module, copied in -------------

# Read all CGI vars into an associative array.
# If multiple input fields have the same name, they are concatenated into
#   one array element and delimited with the \0 character (which fails if
#   the input has any \0 characters, very unlikely but conceivably possible).
# Currently only supports Content-Type of application/x-www-form-urlencoded.
sub getcgivars {
    local($in, %in) ;
    local($name, $value) ;

    # First, read entire string of CGI vars into $in
    if ( ($ENV{'REQUEST_METHOD'} eq 'GET') ||
         ($ENV{'REQUEST_METHOD'} eq 'HEAD') ) {
        $in= $ENV{'QUERY_STRING'} ;

    } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
        if ($ENV{'CONTENT_TYPE'}=~ m#^application/x-www-form-urlencoded$#i) {
                || &HTMLdie("No Content-Length sent with the POST request.") ;
            read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) ;

        } else {
            &HTMLdie("Unsupported Content-Type: $ENV{'CONTENT_TYPE'}") ;

    } else {
        &HTMLdie("Script was called with unsupported REQUEST_METHOD.") ;
    # Resolve and unencode name/value pairs into %in
    foreach (split(/[&;]/, $in)) {
        s/\+/ /g ;
        ($name, $value)= split('=', $_, 2) ;
        $name=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
        $value=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
        $in{$name}.= "\0" if defined($in{$name}) ;  # concatenate multiple vars
        $in{$name}.= $value ;

    return %in ;


# Die, outputting HTML error page
# If no $title, use a default title
sub HTMLdie {
    local($msg,$title)= @_ ;
    $title= "CGI Error" if $title eq '' ;
    print <<EOF ;
Content-type: text/html


    exit ;

#-------------- end of &getcgivars() module --------------------------

Bob StoneIT GuruAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

and what is the question now?
Bob StoneIT GuruAuthor Commented:
Mainly they are whining that they can't read this part very well. How would I clean it up?

o01Item:    HS²Hand Stamps²Stamp Size: HS26 1.75 in diameter +$19.50³Font          : Times Roman Bold³Font Size   : Fit to Size³Signature  : Yes  +$3.00³Art Work : Yes  +$5.00³Reduce/Enlarge Art: Yes  +$2.00³Text Line 1: This is a Stamp³Text Line 2: I use it to stamp things³Text Line 3: IN FACT³Text Line 4: I just used it to³Text Line 5: Stamped this!²r;$29.50²c;11²r;$324.50
> How would I clean it up?
however you like it to look like.

Sorry for my sarcastic comment, but you need to give more information what you want to do.
I can read it, so there is no need for a change ;-)
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Bob StoneIT GuruAuthor Commented:
So can I but we are talking about secretaries being able to read it.

I can't really change the variables names in the shopping cart app without doing a ton of work, just wondering if there is a way to maybe replace characters with a script, like change the ² thingy for a <br> or \n. I have no idea how to do that tho and can't find anything on web.
ok, please save the data into a file and use (assuming Unix/Linux)
  od -x file
to identify that character, please post the hex value of the character
Bob StoneIT GuruAuthor Commented:
I am not sure how to use that command or where to put it in the mail script
oops, this command was not meant to be used in your script
You need it once to identify what's the code of these characters.
Bob StoneIT GuruAuthor Commented:
Ent  Value =  &sup2;
Dec Value =  &#178;
Hex Value =  &#xB2;
assuming your valu in question is in variable $item and you want to replace these chars by a <br> tag, then use something like:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob StoneIT GuruAuthor Commented:
<br> didn't work, but \n did =o)


Instead of -
 o01Item:    HS²Hand Stamps²Stamp Size: HS26 1.75 in diameter +$19.50³Font          : Times Roman Bold³Font Size   : Fit to Size³Signature  : Yes  +$3.00³Art Work : Yes  +$5.00³Reduce/Enlarge Art: Yes  +$2.00³Text Line 1: This is a Stamp³Text Line 2: I use it to stamp things³Text Line 3: IN FACT³Text Line 4: I just used it to³Text Line 5: Stamped this!²r;$29.50²c;11²r;$324.50

 o02Item:    NSC²Round²Stamp Size: HS28 Hand Stamp +$19.50³Name       : Weasal Fizzlebottom²r;$19.50²c;11²r;$214.50

I get -
    Hand Stamps
    Stamp Size: HS25 2 1/2 in x 3 1/2 in +$25.95
    Font          : Helvetica
    Font Size   : Fit to Size
    Signature  : No
    Art Work : No
    Reduce/Enlarge Art: No
    Text Line 1: My Stamp is big
    Text Line 2: I like to stamp things
    Text Line 3: BOOOM!
    Text Line 4: I just stamped this!
    Text Line 5: YAY! I are so happy!

    Self Inking Stamps
    Stamp Size: SI50 1.06 in x 2.56 in +$24.50
    Font          : Helvetica
    Font Size   : Fit to Size
    Ink Color  : Black
    Signature  : Yes  +$3.00
    Art Work : Yes  +$5.00
    Reduce/Enlarge Art: No
    Text Line 1: This is another stamp
    Text Line 2: I like to stamp things
    Text Line 3: Lookie!
    Text Line 4: I just stamped it with
    Text Line 5: This stamp too!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.