use strict; use warnings; my $str = qq{this\nis my short\nstring\n\n}; my $count = 0; for ( split m{\n}, $str, -1 ) { print ++ $count, qq{: $_\n}; }