perl -we 'open N, "<", shift or die; $p = 0; while(defined($n = )) { $s = <> for $p + 1 .. $n + 0; print $s; $p = $n; }' nums text