Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Rearrange hex digits.

by kennethk (Abbot)
on May 24, 2010 at 14:49 UTC ( #841399=note: print w/replies, xml ) Need Help??

in reply to Rearrange hex digits.

I don't see any way of modifying the algorithm of the regular expression to make it more comprehensible (maybe doing it in multiple steps?) but, when I want to make code more comprehensible, my first thought is documentation, and regular expressions can certainly take documentation. Utilizing the x modifier, the regular expression will ignore white space and comments (# delimited). See perlre. I also think uc might be more clear than your tr. Consider:

$job_id = uc $job_id; $job_id =~ s/^(..)(..)(..)(..) # Invert first 4 bytes (..)(..) # More comments ... (..)(..) (.{4}) (.{12}) $ /$4$3$2$1-$6$5-$8$7-$9-$10/x;

or the indentation/comment scheme of your choice.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://841399]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2021-09-28 07:37 GMT
Find Nodes?
    Voting Booth?

    No recent polls found