Perl-Sensitive Sunglasses | |
PerlMonks |
Masking part of a stringby citromatik (Curate) |
on Jun 27, 2007 at 12:53 UTC ( [id://623608]=perlquestion: print w/replies, xml ) | Need Help?? |
citromatik has asked for the wisdom of the Perl Monks concerning the following question: Hi all, monks I'm trying to mask part of a string based on a bit vector. i.e:
To do that I wrote the following script (to deal with a dummy example):
At this point the output of the program is:
To apply the mask I found two possible solutions:
and...
Both outputs as expected:
But I do not feel to taste with any of the two: In real examples (strings to mask having lengths ~10e5), step through both strings or arrays (the string to mask and the bit vector) could be very inefficient and one of the reason to use bit vectors is efficiency building them ($mask1 | $mask2, $mask1 & $mask2, etc...). Is there any way to do the masking without having to traverse all the sequence? Am I in the wrong direction for doing the job? Thanks in advance! citromatik
Back to
Seekers of Perl Wisdom
|
|