in reply to Re: Question why my code is posting a new line
in thread Question why my code is posting a new line

Thanks for the help Athanasius. So are you saying that assigning a variable, and hitting Enter , Perl automatically assigns a "\n" to that variable? Thanks
  • Comment on Re^2: Question why my code is posting a new line

Replies are listed 'Best First'.
Re^3: Question why my code is posting a new line
by GrandFather (Saint) on Dec 18, 2012 at 03:49 UTC

    No. Athanasius is implying that:

    my $price = <STDIN>;

    reads an entire line including the end of line character(s) into $price. Perl doesn't "add" the new line, it was there in the input. chomp may be used to remove a trailing line end.

    Most often the line end is represented in Perl strings as \n regardless of operating system. In various cases is can be other strings (for example when the content of $/ has been changed).

    True laziness is hard work