I agree with ww, it does work as expected, you are concatenating the newline character. trizen suggests a solution to remove that character. However I think the issue here is how to exit the while loop. If you assign and concatenate you attach the exit keystroke onto the variable you are processing. Mixing your control with your data.
There are also modules such as
IO::Prompter which can handle a lot of this for you.
#!/usr/bin/perl -wl
use strict;
my $s;
my $chomp = 1; # actually I do want to remove the newline;
while(<STDIN>){
chomp if $chomp;
unless( /^q$/i ){ # exit from inputting is 'q' or 'Q'
$s .= $_; # concatenate
print $s;
}else{ last }
}
print $s;
exit 0;
nice trick though, hadn't thought of using operators other than simple assignment