[clug] "Casting" in perl.

Andrew Janke a.janke at gmail.com
Mon Jun 22 11:33:26 GMT 2009


Hi all,

I know perl is supposed to be un-typed, but, let's presume I need to
do the equivalent of this:

   unsigned long ul;
   unsigned int ui;

   ul = sdbm_hash("blah");
   ui = (unsigned int)ul;

in perl...  To me this is what comes to mind:

   $ui = unpack("I", pack("V", $ul));

Is there a better way? (or being perl, is there ever a better way? :)

ta


--
Andrew Janke
(a.janke at gmail.com || http://a.janke.googlepages.com/)
Canberra->Australia    +61 (402) 700 883


More information about the linux mailing list