Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: homepage.vbs decode

by jeroenes (Priest)
on May 10, 2001 at 19:05 UTC ( #79425=note: print w/replies, xml ) Need Help??


in reply to homepage.vbs decode

With tr it gets simpler:
tr/\017\020\021\022/\012\015\040\011/; #Gets the subst tr/\023-\200/\021-\176/; #converts ranges
If you need other ranges, they are easily made.

Jeroen<br. "We are not alone"(FZ) Oops.. alfie is right. Perl indeed only uses the first occurence of a char in the 'search' string, it is documented in perlop:

If multiple transliterations are given for a character, only the first one is used: tr/AAA/XYZ/ will transliterate any A to X.

Replies are listed 'Best First'.
Re: Re: homepage.vbs decode
by alfie (Pilgrim) on May 10, 2001 at 19:29 UTC
    *beeep* Wrong answer, sorry. You are converting \021 to \036 in the endeffect, and that is not what I'd have expected. Sure, you could change the \040 in the first line to a \042 to fix that but what if there is a character lower than \023 in the original string?

    So, taking this, it seems that the following might be the solution:

    tr/\017\020\021\022\002-\200/\012\015\040\011\000-\176/;
    For with a quick test it seems that tr takes the first occurence of a character and doesn't care if there is another one later. Is that right, is that maybe even documented on it so I can be sure when using it?
    --
    use signature; signature(" So long\nAlfie");

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-05-17 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (65 votes). Check out past polls.

    Notices?