Musa Yıldırım Musa Yıldırım - 6 months ago 14
Perl Question

Space error in perl

I have written this code:

my $dizin = "/home/$kullaniciadi/public_html/meme.txt";
print $dizin;


This result comes:

/home/neguzel
/public_html


But I want it to be
/home/username/public_html
. I don't want it to be

/home/usernames
/public_html


How can I remove that line break?

Answer

You need to chomp your input. It has a line break. chomp will remove that newline character \n for you.

my $kullaniciadi = <STDIN>;
chomp $kullaniciadi;

my $dizin = "/home/$kullaniciadi/public_html/meme.txt";
print $dizin;