use strict; #These two lines are almost-always use warnings; #a good idea print "Enter your data.\n"; print "Type .. at the beginning of a line to quit.\n"; open my $output_file,'>','output_file.txt' or die "We got trouble here!\n"; LOOP: while () { my $data = $_; chomp $data; last LOOP if ($data =~ m/^\.\./); print $output_file "$data\n"; } close $output_file; exit;