my @dirs; while (<>) { m/^The dir is '([^']*)' and there are \d* files/ and push @dirs, $1; }