On Thu, May 09, 2002 at 02:22:36PM +0200, Ankit Gupta wrote: > I am trying to convert a string to Hexadecial format. For example I am > trying to convert <[EMAIL PROTECTED]> to hexadecimal > format and it gives me result as 0 . Similary if I try to convert such type > of different strings, it still gives me same result of 0. Could any one > throw some light as where I am wrong.
You don't mention how you tried to convert the string to hexadecimal format, so I can't really comment on why you're getting a result of 0. You're also not very specific on what you mean by "hexadecimal format". I'm assuming you meant you want each character in the string to be converted to its hexadecimal equivalent. Based on that, here's one method: my $string = '<[EMAIL PROTECTED]>'; my $hex_string = ''; foreach my $c (split(//, $string)) { $hex_string .= sprintf("%02x", ord($c)); } print "original: $string\n"; print "hex representation: $hex_string\n"; Is that what you were looking for? You wouldn't, by any chance, be trying to convert a string for use in a URL, would you? If so, there is a module for that; URI::Escape. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]