in reply to Regular expression match in file
while (<>) { if (/^level (\d+)/) { $i = $1; } else { $array .= $_; } } [download]
Does that do the trick?