Reputation: 435
Why would perl's length function add an extra character in its result?
I have this simple code.
#!/usr/bin/perl
print "enter text ->";
my $variable;
my $variable = <>;
$length = length($variable);
print "$length\n";
But when I enter the text "hi" for example, the output of length is 3, while I'm expecting it to be 2.
Upvotes: 1
Views: 133