Sorry for the delay in getting back to you. I've adapted your technique somewhat: sub eily{
my $str = shift;
my @b = map[ ( 1e99, 0 ) x 2 ], 1 .. 256;
for my $y ( 0 .. $HEIGHT-1 ) {
my $s = \substr( $$str, $y * $WIDTH, $WIDTH );
my $t = ' ' . $$s ^ $$s;
chop $t;
while( $t =~ m[[^\0]\0*]g ) {
my $c = ord substr $$s, $-[0], 1; #, $-[0], $+[0];
$b[ $c ][ LEFT ] = $-[0] if $-[0] < $b[ $c ][ LEFT
+ ];
$b[ $c ][ RIGHT ] = $+[0]-1 if $+[0]-1 > $b[ $c ][ RIGH
+T ];
$b[ $c ][ TOP ] = $y if $y < $b[ $c ][ TOP
+ ];
$b[ $c ][ BOTTOM ] = $y if $y > $b[ $c ][ BOTT
+OM ];
}
}
return \@b;
}
and the results are impressive: C:\test>\perl22\bin\perl 1176081.pl -WIDTH=10000 -HEIGHT=10000
yr() took 12.478694
buk3() took 8.195635
dave() took 1.876719
eily took 0.888511
C:\test>\perl22\bin\perl 1176081.pl -WIDTH=20000 -HEIGHT=20000
yr() took 18.774189
buk3() took 32.063918
dave() took 5.701784
eily took 2.409520
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
In the absence of evidence, opinion is indistinguishable from prejudice.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|