Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: I wrote some clever code - can the comment "defuse" it?

by Aristotle (Chancellor)
on Jun 18, 2003 at 10:02 UTC ( #266772=note: print w/replies, xml ) Need Help??

in reply to Re: I wrote some clever code - can the comment "defuse" it?
in thread I wrote some clever code - can the comment "defuse" it?

I need slices of varying length from the input array. There's currently no way to express this succintly - the splice solution is merely the least unsatisfactory given my biases. It's not good, no, but the alternative is even worse.

The other approach would have been to loop over the letter array and manually compare previous and current property. Conceptually, that's a very basic form of pattern matching - so why not use the native pattern matching mechanism Perl already offers?

The problem is that the regex engine only works against characters in a string - if it was possible to run against any ordered sequence of elements, regardless of representation (whether that be the traditional characters in a string or elements in an array or maybe something else completely like records in a database), I wouldn't need to go through mapping to a string first. Rather than get a series of strings out of the match, I'd get exactly the series of slices I'm building manually here.

Since I can only have the former, I have to somehow construct the latter from that. And a series of slice lengths to take from an array is not elegantly expressible in current Perl idioms.

Makeshifts last the longest.

  • Comment on Re^2: I wrote some clever code - can the comment "defuse" it?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://266772]
[ambrus]: We're not really sure. There are some other contenders like libjpeg, and it's not easy to tell how you even measure this.
[ambrus]: But we figured it's close.
[Corion]: If you take Android as the baseline, that makes all three a likely contender

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-09-25 14:21 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (280 votes). Check out past polls.