#!/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.
In reply to Re^4: An overlapping regex capture
by Peter Keystrokes
in thread An overlapping regex capture
by Peter Keystrokes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |