Syntactic Confectionery Delight | |
PerlMonks |
in reply to using bits to print part of a string
Updated: Using tr/ instead of s/ at line 10 speeds the method up.#!/usr/bin/perl use warnings; use strict; my $string = join q(), map int rand 10, 1 .. 400_000; my $mask = join q(), map int rand 2, 1 .. 400_000; $mask =~ tr/01/\x00\xff/; my $result = $string & $mask; $result =~ tr/\x00//d; print $result;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: using bits to print part of a string
by Anonymous Monk on Mar 15, 2013 at 16:44 UTC |