2 Replies - 6368 Views - Last Post: 23 August 2013 - 10:44 AM

#1 frankmau5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-January 13

don't understand why i am getting a newline for

Posted 23 August 2013 - 09:23 AM

i can not understand why i am getting a new line after my variable $username can someone explain this to me please :)/>


print "what is you name ?\n";

$username = <STDIN>;

print "hello $username";
print " nice to meet you \n";



i have also tried this

print "what is you name ?\n";

$username = <STDIN>;

print "hello $username nice to meet you \n"



Is This A Good Question/Topic? 0
  • +

Replies To: don't understand why i am getting a newline for

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2499
  • View blog
  • Posts: 3,950
  • Joined: 21-June 11

Re: don't understand why i am getting a newline for

Posted 23 August 2013 - 10:21 AM

When you read a line of user input, the resulting string will contain a line break at the end. You can remove a trailing line break from a string using the chomp function.
Was This Post Helpful? 1
  • +
  • -

#3 frankmau5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-January 13

Re: don't understand why i am getting a newline for

Posted 23 August 2013 - 10:44 AM

Ok thanks for the help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1