http://qs1969.pair.com?node_id=556206


in reply to A first attempt

OK, I'll bite...
I don't understand how/why the scalars are getting alpha characters assigned to them from the numbers input.

Please help for those of us that have only gotten through the llama!

EDIT:
What causes it to 'translate' to the chars? i.e. What if I wanted the $a to store the IP address 1.2.3.4?

Replies are listed 'Best First'.
Re^2: A first attempt
by jdalbec (Deacon) on Jun 19, 2006 at 23:08 UTC

    It's called a version string. Any "number" with more than one decimal point is converted to the corresponding characters. This is deprecated, but all's fair in obfuscation.

    There's no "IP address" type in Perl. What are you doing with the IP address? If you need a packed IP address, 1.2.3.4 will work, but the accepted way to do this is
    use Socket; $a = inet_aton("1.2.3.4");
    If you want the string "1.2.3.4" then use quotation marks.
      Thanks for the info. I was only using the IP address as a "what if". For example, I could imagine a situation where I might have the following:
      $string = "My IP address is 10.1.1.1!\n"

      Or, better yet, what if I had a function that grabbed my current IP address (let's call it $IP) and then I changed the above to:
      $string = "My current IP address is $IP\n"

      Thanks in advance, I'm just trying to grasp this more fully. It is certainly a neat item to mess around with...

      Also, is this discussed in any of the O'Reilly Perl books? Mine are at work right now, but I'll page through them when I go in tonight.

Re^2: A first attempt
by fatalserpent (Initiate) on Jun 20, 2006 at 01:11 UTC
    I only finished the Perl wikibook (which is woefully incomplete and can be found here) when I wrote this... I also looked at some obfuscated code...