in reply to Re^3: printing sub return values to a file
in thread printing sub return values to a file
That clobbers the parent's $_. Fixed:
sub get_oligo_seqs{ my ($fh) = shift; my @seqs; while(my $rec = <$fh>){ my @fields = split /\t/, $rec; my $oligos = $fields[1]; push(@seqs,($oligos)); } return @seqs; }
This seems simpler to me:
sub get_oligo_seqs{ my ($fh) = shift; my @seqs; while(my $rec = <$fh>){ push @seqs, ( split /\t/, $rec )[1]; } return @seqs; }
Why stop there?
sub get_oligo_seqs{ my ($fh) = shift; return map { ( split /\t/ )[1] } <$fh>; }
|
|---|