Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: A question About Array Indexing

by poj (Prior)
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050920]
help
Chatterbox?
[GotToBTru]: you could, yes
[GotToBTru]: whether or not it would be the best tool for that job .. that is another question

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-02-22 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (335 votes). Check out past polls.