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}; } #### 1: this 2: is my short 3: string 4: 5: