#!/usr/bin/perl use strict; # initially, create a scalar that is 1 line long my $line = ">"."\n" x 1; my $incr = 1; while (1) { # run until it crashes while ($line =~ /^(>.*)\n(^(?!>).*\n)+/gm) { print "Number of lines: ", length($line)-1,"\n"; } # add another line $line .= "\n" x $incr; }