bent4gud has asked for the wisdom of the Perl Monks concerning the following question:

I need to provide an ASCII equivalent to any printable character that a user inputs, one character at a time. I have been given the stricture to use unpack. I cannot find the way. Please give me wisdom. Bob

Replies are listed 'Best First'.
Re: ASCII Conversion
by fruiture (Curate) on Oct 06, 2002 at 20:18 UTC

    Well, check `perldoc -f unpack` and see `perldoc -f pack` for the template-characters. You might also want to see what ord does (`perldoc -f ord`).

    Where exactly is your problem?

    --
    http://fruiture.de
      I am a newbie's newby. I am taking an on-line course through a local university in AZ. My problem is that the book we are using for a textbook does not explain anything like what the instructor is asking for, and he doesn't answer his emails. He even gives references which do not even have anything to do with the question. So I am looking for an answer. There is more to the problem than what I am asking, but I can get the rest if I can figure out how to use unpack to come up with the ASCII values for the printable characters. Oh Yeah, when I do a perldocs -f unpack I get an error both on my Windows system and my UNIX (Solaris) system. Bob
        try perldoc -f unpack instead of perldocs -f unpack
        note there is no s in perldoc
        Update: Oh, I forgot, you can also go to unpack and get the same information.

        jjdraco
        learning Perl one statement at a time.
Re: ASCII Conversion
by LEFant (Scribe) on Oct 06, 2002 at 20:20 UTC
    ord EXPR
    ord
    Returns the numeric (ASCII or Unicode) value of the first character of EXPR. If EXPR is omitted, uses $_. For the reverse, see /chr. See utf8 for more about Unicode.

    See your perldoc or the nearest Camel for usage of unpack.

    RBL

      I appreciate the fact that ord does what I want, but I must use unpack. See my reply to fruiture. Bob
Re: ASCII Conversion
by rdfield (Priest) on Oct 07, 2002 at 12:21 UTC
    The documentation provided at unpack provides a very specific example that may help. Hint, search for the phrase "same as ord".

    rdfield