[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: perl help
On 13 Jan 2001, Moyukh wrote:
> Hi all,
> well i am new to perl programming..i am trying out some
> socket programming..
> when i send 0 (zero) it reaches as ascii zero that is 48,
> even if i try to send 0x0 then also it goes as ascii zero.
> what ever i send it all goes as ascii, the second problem is
> how to cover the data recived as ascii character to int....
Well, in perl the difference between a character & an interger is
dim. Perl treats them appropriately based on the context. So you can have
$String = "1000"; $String++;
During the string assignment, 1000 is considered as a string. But the ++
operator treats it as a number, without you explicitly specifying
Now, coming to your problem, what exactly is your requirement ? Why do u
want to convert from ascii 2 integer ..? You can simply do a
syswrite() on one end (or send() if u're using UDP) & sysread (or recv) on
the other end. U'll always get the same data. Socket programming in perl
is damn easy, if u use the standard modules, such as IO::INET::Socket.
If u want I can send u sample code.