diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-04-28 10:54:31 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-04-28 10:54:31 +0100 |
| commit | 1bc56a1fa4ec9471b6e6b99eadad97763e3fc2c8 (patch) | |
| tree | 08536eab0e74816d7609e914e55b261d897b1a15 /challenge-110 | |
| parent | 52a191f723ab56240a9624d222c35391e95cb185 (diff) | |
| download | perlweeklychallenge-club-1bc56a1fa4ec9471b6e6b99eadad97763e3fc2c8.tar.gz perlweeklychallenge-club-1bc56a1fa4ec9471b6e6b99eadad97763e3fc2c8.tar.bz2 perlweeklychallenge-club-1bc56a1fa4ec9471b6e6b99eadad97763e3fc2c8.zip | |
stop using array - but printing every result...
Diffstat (limited to 'challenge-110')
| -rw-r--r-- | challenge-110/james-smith/perl/ch-2.pl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/challenge-110/james-smith/perl/ch-2.pl b/challenge-110/james-smith/perl/ch-2.pl index c71cbca113..e02c2735a3 100644 --- a/challenge-110/james-smith/perl/ch-2.pl +++ b/challenge-110/james-smith/perl/ch-2.pl @@ -58,7 +58,7 @@ sub transpose_split { close $fh; ## Generate transpose open $fh, '>', $_[1]; - say {$fh} join ',', map {shift @{$_} } @in while @{$in[0]}; + say {$fh} join ',', map {shift @{$_} } @in while @{$in[0]}; close $fh; } @@ -89,7 +89,7 @@ sub transpose_seek { ## entry and output results. while( $pos[0][0] < $pos[0][1] || length $pos[0][2] ) { - my @line; + my $j=''; foreach(@pos) { ## Grab extra data for the row if we have got an incomplete ## field {missing a "," and still data to read} @@ -101,9 +101,11 @@ sub transpose_seek { ## added to end $_->[0]+=$BYTES; } - push @line, $_->[2] =~ s{^([^,\r\n]+)[,\r\n]*}{}; + $_->[2] =~ s{^([^,\r\n]+)[,\r\n]*}{}; + print {$ofh} $j,$1; + $j||=','; } - say {$ofh} join q(,), @line; + say {$ofh} ''; } } |
