Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 328697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:31:10+00:00 2026-05-12T09:31:10+00:00

Basically I have a database where I get $lastname , $firstname , $rid ,

  • 0

Basically I have a database where I get $lastname, $firstname, $rid, $since, $times and $ip from.

Using a Perl script, I format the data to send it via e-mail. Since the $lastname and $firstname can contain special chars (for instance ä, ü, ß, é,…) I first decode the strings.

my $fullname = decode("utf8", $lastname) . ', ' . decode("utf8", $firstname);
my $send = swrite(<<'END', $ip, $fullname, $rid, $since, $times);
@<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<<<<< @>>END

Without decode, the special chars are garbage (ä becomes À) and the rest is OK.
With decode, everything is fine except the lines with name containing special chars have a couple of < too many.

Why is that? And how do I remove them?

Edit: swrite is from perldoc perlform

sub swrite {
  my $format = shift;
  $^A = '';
  formline($format, @_);
  return $^A;
}

Edit2:
The problem is not the terminal nor STDOUT. I use:

use Mail::Sender;
use vars qw($sender);
#...
$sender->MailMsg({to => $mailto, 
  cc=> "", 
  bcc => "", 
  subject => "subject", 
  msg => $send});

And the characters are badly shown when receiving the email.

Edit 3:
The data I get is already scrambled. I get ‘À’ instead of ‘ä’ and that’s why my format fails, because the number of chars decreases when using decode.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:31:10+00:00Added an answer on May 12, 2026 at 9:31 am

    I have never had the desire to learn about formats. This is a bad answer because I am unable to offer any insight into your problem and/or potential solutions, but others have already done that. I am going to offer two suggestions for replacements.

    The first one, Perl6::Form ought to be useful as a better format although I had never used it until I put together this example today. On the other hand, I have used Text::Table and it is very useful for creating tables in plain text (most of the time, I just generate HTML, but email is still one of those places where plain text is plainly better).

    Perl6::Form example:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use Perl6::Form;
    
    my @data = (
        ['127.0.0.1', 'Johnny Smithey', 'JLNSJIV', 14, 5],
        ['127.0.0.2', 'Ömer Seyfettin Şınas', 'OSS3', 25, 5],
    );
    
    for my $data_ref ( @data ) {
        print format_data($data_ref);
    }
    
    sub format_data {
        my ($data) = @_;
        return form
            '{<<<<<<<<<<<<<<<} {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<} ' .
            '{<<<<<<<<<<} {<<<<<<<<<<<<<<} {>>}',
            @$data;
    }
    

    Text::Table example:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use Text::Table;
    
    my %common_options = (
        align => 'left',
        title_align => 'center',
    );
    
    my $sep = \' ';
    
    my $table = Text::Table->new(
        {
            title  => 'IP Address',
            sample => '<' x 15,
            %common_options,
        },
        $sep,
        {
            title => 'Full Name',
            sample => '<' x 34,
            %common_options,
        },
        $sep,
        {
            title => 'RID',
            sample => '<' x 10,
            %common_options,
        },
        $sep,
        {
            title => 'Since',
            sample => '<' x 14,
            %common_options,
        },
        $sep,
        {
            title => 'Times',
            sample => '>' x 2,
            align => 'right',
            title_align => 'center'
        },
    );
    
    $table->rule('');
    
    $table->load(
    ['127.0.0.1', 'Johnny Smith-Jones', 'JLNSJIV', '20090814010203', 5],
    ['127.0.0.2', 'Ömer Seyfettin Şınas', 'OSS3', '20071211101112', 3],
    ['192.168.172.144', 'Jane Doe', 'JD156', '20080101010101', 1],
    );
    
    print $table->table;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 413k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can get the desired result with the code below.… May 15, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer I am assuming that you are using Java as the… May 15, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer This is the most common way of parsing and storing… May 15, 2026 at 8:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.