in reply to Re^3: An overlapping regex capture
in thread An overlapping regex capture
#!/usr/bin/perl use strict; use warnings; open my $fh, '<',"human_hg19_circRNAs_putative_spliced_sequence.fa",or + die $!; my %id2seq; while(<$fh>){ my $id = ''; chomp; if($_ =~ /^>(.+)/){ $id = $1; }else{ $id2seq{$id} .= $_; } } foreach my $id (keys %id2seq){ my $filename = (split /\|/, $id)[0]; open my $out_fh, '>>', "$filename" or die $!; print $out_fh ">".$id."\n",$id2seq{$id}, "\n"; close $out_fh; } close $fh;
How do I integrate the value I've split and extracted into the naming of the file, because it's stating that it's uninitialised?
Although, I thought that it was clearly initialised/defined here:
my $filename = (split /\|/, $id)[0]; open my $out_fh, '>>', "$filename" or die $!;
Or maybe I'm just misunderstanding the scope? Where do I place the $filename in the loop?
Pete.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: An overlapping regex capture
by poj (Abbot) on Jun 22, 2017 at 15:33 UTC | |
|
Re^5: An overlapping regex capture
by 1nickt (Canon) on Jun 22, 2017 at 12:01 UTC | |
by Peter Keystrokes (Beadle) on Jun 22, 2017 at 18:17 UTC | |
by 1nickt (Canon) on Jun 22, 2017 at 21:24 UTC |