uping and downing letters

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default uping and downing letters

    Howdy,

    looking for a way to change letter

    # example
    # a would become b, A would become B, b=c, c=d etc for upping or
    # b would become a, B would become A, etc.

    Ive tried a couple different things and just cant come up with a
    way to do it. Would converting it to hex then changing help. and if so
    how would i increment it. Or does there happento be a module with this
    already done. I can do it the long way with lots of ifs but was hoping
    there would be a less code intensive, simpler way to do it.
    I have to be able to use a-z,A-Z,0-9, - and _ and after upping and
    downing I have to be able to get the original letter back.

    code, links, manpages would be appreciated

    thanks john

    john Guest

  2. Similar Questions and Discussions

    1. Letters printing on top of each other.
      I have a problem can't find support on. The pdf file has letters appearing on top of each other. It only happens 1 time every 3 pages or so. The word...
    2. Shapely Letters?
      What's the best way for me to place text into and a shape and actually take form of that shape (Ex. the word "heart" would actually be the shape of a...
    3. Capital Letters
      I have a form which people use to register in a database. The form passes the input data to an asp page that then updates the database. The thing...
    4. how to emboss letters
      Hi, how do you make writing look like it's been stamped into leather? or stainless steel - I know it's got something to do with the punch tool, but...
    5. outline of letters
      i am trying to outline some letters, i have 2 gold script letters that i did, but now i want to outline then with a line black outline, thx in advance
  3. #2

    Default Re: uping and downing letters

    john <wenjoh26@emNOSPAMail.pct.edu> wrote:

    : looking for a way to change letter
    :
    : # example
    : # a would become b, A would become B, b=c, c=d etc for upping or
    : # b would become a, B would become A, etc.
    :
    : Ive tried a couple different things and just cant come up with a
    : way to do it.

    What techniques have you tried? How were those techniques
    unacceptable?

    : I have to be able to use a-z,A-Z,0-9, - and _ and after upping and
    : downing I have to be able to get the original letter back.

    The spec needs a little more fleshing out.

    How should the edge cases be handled? For example, should an
    incremented 'z' become whatever is next in the ASCII character set,
    should it wrap back to 'a', turn into 'A', or something else? What
    should an incremented or decremented '-' or '_' become?

    Do you wish to change all the characters in a string, or only one
    character?

    The chr() and ord() functions may be what you want.
    Or the tr/// operator may be more useful.
    It depends.

    Jay Tilton Guest

  4. #3

    Default Re: uping and downing letters

    In article <Xns93EDEFDD2B9BFwenjoh26emNOSPAMailp@216.65.98.9> ,
    john <wenjoh26@emNOSPAMail.pct.edu> wrote:

    : Howdy,
    :
    : looking for a way to change letter
    :
    : # example
    : # a would become b, A would become B, b=c, c=d etc for upping or
    : # b would become a, B would become A, etc.

    This should get you started:

    % cat try
    #! /usr/local/bin/perl -l

    $_ = "a -> b, b -> c, c -> a";

    print;

    tr[abc]
    [bca];

    print;
    % ./try
    a -> b, b -> c, c -> a
    b -> c, c -> a, a -> b

    : [...]

    See the documentation on Perl's tr/// operator in the perlop manpage.

    Hope this helps,
    Greg
    --
    There are more instances of the abridgement of the freedom of the people
    by the gradual and silent encroachment of those in power, than by violent
    and sudden usurpation.
    -- James Madison
    Greg Bacon Guest

  5. #4

    Default Re: uping and downing letters

    john wrote:
    >
    > Thanks for the help as for -,_,z,Z etc. I am just looking to push to the
    > next character in askii. And I am recieving the letters in a string but
    > have written the code to parse the string into an array of chars
    To go "up":

    $string =~ tr/\x0-\xFF/\x1-\xFF\x0/;

    To go back "down" again:

    $string =~ tr/\x1-\xFF\x0/\x0-\xFF/;


    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

  6. #5

    Default Re: uping and downing letters

    john wrote:

    (snipped)

    > # a would become b, A would become B, b=c, c=d etc for upping or
    Add one to the ord() value of your character.

    > # b would become a, B would become A, etc.
    Subtract one from the ord() value of your character.

    Print using chr($new_ord_value).

    Don't be surprised if you exceed or fall below printable
    values for characters. Testing will disclose what happens.


    My new Purl Gurl Net is slowly propagating. Please be patient.
    For some, your DNS records may not update for a week or more.

    [url]http://www.purlgurl.net[/url]

    Complete Perl Documentation.
    Complete Apache Documentation.
    Learn to speak Choctaw and lots of fun stuff!


    Purl Gurl
    --

    #!perl

    @Array = qw (O t q k 32 F t q k 32 Q n b j r);

    for (@Array)
    {
    if ($_ == 32)
    { print chr ($_); }
    else
    {
    $ord = (ord ($_)) + 1;
    print chr ($ord);
    }
    }


    PRINTED RESULTS:
    ________________

    Purl Gurl Rocks
    Purl Gurl Guest

  7. #6

    Default Re: uping and downing letters

    John W. Krahn (krahnj@acm.org) wrote on MMMDCLVIII September MCMXCIII in
    <URL:news:3F59684D.A654B57F@acm.org>:
    ,, john wrote:
    ,, >
    ,, > Thanks for the help as for -,_,z,Z etc. I am just looking to push to the
    ,, > next character in askii. And I am recieving the letters in a string but
    ,, > have written the code to parse the string into an array of chars
    ,,
    ,, To go "up":
    ,,
    ,, $string =~ tr/\x0-\xFF/\x1-\xFF\x0/;

    Since he said ASCII, he wants:

    $string =~ tr/\x0-\x7F/\x1-\x7F\x0/;

    ,, To go back "down" again:
    ,,
    ,, $string =~ tr/\x1-\xFF\x0/\x0-\xFF/;

    And that would be:

    $string =~ tr/\x1-\x7F\x0/\x0-\x7F/;


    Abigail
    --
    #!/opt/perl/bin/perl -- # Remove trailing newline!
    BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;
    truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ
    Abigail Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139