Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
and a Hash of Arrays that has ranges of numbers in pairs :>my_id ---------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +----------------------------
What I want to do, is to substitute the - with A for every range that is mentioned in all the arrays of the HoA.123-186 188-259 263-340 1-93
How will I continue in order to substitute, e.g. all characters between position 123 and 186 from - to A?my $id = '------------------------------------------------------------ +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +--------------------------------------------------------------------- +-------------------------------------- '; foreach my $l ( 0 .. $#{ $HoA{$id} } ) { my $separate_range = $HoA{$id}[$l]; if($separate_range=~/(\d+)\-(\d+)/) { my $hit_beg=$1; my $hit_end=$2; my $hit_length=$hit_end-$hit_beg+1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you perform this substitution?
by toolic (Bishop) on Jun 25, 2014 at 11:36 UTC | |
|
Re: How do you perform this substitution?
by Laurent_R (Canon) on Jun 25, 2014 at 17:50 UTC | |
|
Re: How do you perform this substitution?
by AnomalousMonk (Archbishop) on Jun 25, 2014 at 18:26 UTC | |
|
Re: How do you perform this substitution?
by ww (Archbishop) on Jun 27, 2014 at 00:35 UTC | |
|
Re: How do you perform this substitution?
by Anonymous Monk on Jun 25, 2014 at 11:26 UTC | |
|
Re: How do you perform this substitution?
by Anonymous Monk on Jun 25, 2014 at 12:06 UTC | |
by Anonymous Monk on Jun 25, 2014 at 12:48 UTC |