Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: char substitution without regexes

by jwkrahn (Abbot)
on Sep 30, 2010 at 17:59 UTC ( [id://862818]=note: print w/replies, xml ) Need Help??


in reply to Re: char substitution without regexes
in thread char substitution without regexes

Yes, but, that uses a regex and the OP said "without regexes".

  • Comment on Re^2: char substitution without regexes

Replies are listed 'Best First'.
Re^3: char substitution without regexes
by ikegami (Patriarch) on Sep 30, 2010 at 18:10 UTC

    It passes a pattern, but it's actually special-cased not to use the regex engine.

    Ok, so I did it without thinking.

    print map $complement{$_}, reverse unpack '(a)*', $chain;

      Now you've got it!   :-)

      By the way, which do you think would be more efficient, reversing the list, or reversing the string first?

        Reversing an array of SV* or reversing an array of char (assuming UTF8=0)? We're talking about the same CPU ops.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2026-04-10 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.