while () { $i++; push(@fnote, $1) if ($_ =~ /(.+)\n/); } $, = "\n"; print @fnote;