for my $line (split "\n", $boxdata) { my ($chr, $x1, $y1, $x2, $y2, $page) = $line =~ m{ ^ (\S) \ (\d+) \ (\d+) \ (\d+) \ (\d+) \ (\d+) $ }x; }