#!/usr/bin/perl -wl use strict; my $s; my $chomp = 1; # actually I do want to remove the newline; while(){ chomp if $chomp; unless( /^q$/i ){ # exit from inputting is 'q' or 'Q' $s .= $_; # concatenate print $s; }else{ last } } print $s; exit 0;