in reply to Re: Re: Requiring backtracking a certain number of times
in thread Requiring backtracking a certain number of times
what I really want is some way of addressing all the characters in a string/number, apply some function to it that returns a number, then add those numbers up.
Use your favourite sum(), and your favorite some_function() ;)$_=6491; sum(some_function(split//));
s/(\d)/$s+=$1/ge; # $s is the sum... # Which leaves garbage in $_, but is a single stroke shorter than: $s+=$_ for split//; # But thenagain, this is even shorter: $s+=$_ for/./g;
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Requiring backtracking a certain number of times
by ferrency (Deacon) on Apr 04, 2002 at 18:24 UTC | |
by dragonchild (Archbishop) on Apr 04, 2002 at 19:06 UTC |