use strict; use warnings; while (<>) { print "[", $_, "]\n";#in your case, you would save this to an array, or if you want scalar reset local $/ }