Perl Variable Concatenation Problem

I just trying to learn PERL. I have trying this line, but the concatenation was not done.

$host=qx(hostname -s);
my $day=qx(date +%A);
print $fileType;
When I executing this I'

ll Get a output like, one by one


But I need a output like ldap-Thursday.tgz Please help me in this. Thanks in Advance.

You need to chomp the values for both variables before joining them into $fileType. Save the following code snippet to a file named

use strict;
use warnings;
my $host = qx(hostname -s);
my $day = qx(date +%A);
chomp $host;
chomp $day;
my $fileType = "$host-$day.tgz";
print "$fileType\n";

Then run as


Refer to the attached image for the result.

Hope it helps :smile:.


Thank you…! It’s working well…! Now i got the exact output…!

I am glad to hear that. Don’t hesitate to come back to each time you have a question. We look forward to helping you.

I just beginner in this field. Once I get a better knowledge then it will be useful to provide a valid answer. Surely I’ll be active after that. I’m frequently following this forum. It was so helpful to me. Thank you