in reply to Re: Return values from package methods
in thread Return values from package methods

My signature is simply prints the number of the post as per the count of number of write-ups on my home node (and as such my signature can be seen to change between posts). Whilst I could have implemented this simply with something like perl -le 'print 636', I decided to make it a little more interesting.

The pack function takes a list of values and converts these to the internal machine-level representation of the values as per the first argument to this function known as the "template". In my signature, this is used to convert a string with a 32-bit binary number into a machine-level representation of this value. The reverse of this is performed with the unpack function which converts from an internal machine-level representation to a string based again upon the template argument to the function. In the case of my signature, this outputs a big-endian order unsigned long integer representing the post number.

 

perl -le 'print+unpack"N",pack"B32","00000000000000000000001001111100"'

Replies are listed 'Best First'.
Re: Re: Re: Return values from package methods
by SavannahLion (Pilgrim) on Aug 22, 2003 at 00:04 UTC
    I guess something must be flaky with my installation of Perl (5.8.0 Win) on this machine. When I do a Copy & Paste into the command line, it doesn't do anything. goes through without any errors. Turning on the w flag just blurts out

    Useless use of a constant in void context at -e line 1.

    So I create a script file and edited the line you have a bit and I get back an answer of 636.

    So I guess I must have something misconfigured or forgot something or something :(

    Oh well....

    Oh yeah, I guess I better give you your hijacked thread back.

    Thanks for you patience.

      I guess something must be flaky with my installation of Perl (5.8.0 Win) on this machine. When I do a Copy & Paste into the command line, it doesn't do anything. goes through without any errors.

      This is a Windows command line quoting issue - Simply rearrange the single and double quotes as I have in the signature of this post and it should all work fine :-)

       

      perl -le "print+unpack'N',pack'B32','00000000000000000000001001111110'"