Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: A question About Array Indexing

by poj (Priest)
on Aug 26, 2013 at 08:28 UTC ( #1050920=note: print w/ replies, xml ) Need Help??


in reply to A question About Array Indexing

I'm guessing this is sort of what you are trying to do ;

#!perl use strict; my $str = '0000000NNNN00NNN0NNN0N0N0NN0N'; my @str = split '',$str; # input my @mask = map{ 'N' }(0..$#str); while (<DATA>){ chomp; my (undef,$start,$end) = split "[,\t]",$_; for my $ix ($start..$end){ $mask[$ix-1] = ' '; } } # process my @output=(); for my $ix (0..$#str){ $output[$ix] = ($mask[$ix] eq 'N') ? 'N' : $str[$ix]; } # output print 'mask ',join '',@mask,"\n"; print 'string ',join '',@str,"\n"; print 'result ',join '',@output,"\n"; # intervals no,start,end __DATA__ 1,2,4 2,6,10 3,20,25 4,28,28
poj


Comment on Re: A question About Array Indexing
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050920]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2015-07-05 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls