| 1 | package Games::Nonogram::Loader::File; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 0 | ▶ | sub load { | ||||||||
|
Subroutine
load: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 7 | 0 | my ($class, $file) = @_; | |||||||||
| 8 | |||||||||||
| 9 | 0 | my ($height, $width, @lines); | |||||||||
| 10 | 0 | ▶ | open my $fh, '<', $file or die "Cannot open $file"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 0 | ▶ | while(<$fh>) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | chomp; | |||||||||
| 13 | 0 | ▶ | next if /^#/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | ▶ | if ( $_ eq '' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 0 | ▶ | unless ( $height ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | $height = scalar @lines; | |||||||||
| 17 | 0 | next; | |||||||||
| 18 | } | ||||||||||
| 19 | 0 | last; # should be the end of the column clues | |||||||||
| 20 | } | ||||||||||
| 21 | 0 | push @lines, $_; | |||||||||
| 22 | } | ||||||||||
| 23 | 0 | $width = (scalar @lines) - $height; | |||||||||
| 24 | |||||||||||
| 25 | 0 | return ($height, $width, @lines); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 2 | 1; | |||||||||
| 29 | |||||||||||
| 30 | __END__ | ||||||||||