Re: Data Conversion ?

2009-11-07 Thread Alexander Krasnorutsky
On Fri, 2009-11-06 at 17:21 -0500, Nathan Gibbs wrote:
> How would I get the length of a string as returned by length () into
> 
> a 4 byte unsigned integer in  network byte order
> 
> Thanks
> 
> -- 
> But there's no sense crying over every mistake.
> You just keep on trying till you run out of cake.
> And the Science gets done.
> And you make an income.
> For the people who are still alive.
> 

It's simple.

$unsigned_4byte_int = pack 'N', length($your_string);

-- 
Krasnorutsky Alexander.


-- 
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Data Conversion ?

2009-11-07 Thread Nathan Gibbs
* Alexander Krasnorutsky wrote:
> On Fri, 2009-11-06 at 17:21 -0500, Nathan Gibbs wrote:
>> How would I get the length of a string as returned by length () into
>>
>> a 4 byte unsigned integer in  network byte order
>>
>> Thanks
>>
>>
> 
> It's simple.
> 
> $unsigned_4byte_int = pack 'N', length($your_string);
> 

Thank You, it worked great.
Its not so simple when I have no idea what a 4 byte unsigned integer in
 network byte order even is.  I thought I would need to use pack, but
had no idea how it worked.

I'm still clueless & learning, but I greatly appreciate the help of
people who know more than me.

Thank You very much.

P.S.
If anyone on this list uses the mon software to monitor their networks
There are a set of monitors at http://www.cmpublishers.com/oss.
The answer to this question was used in the clamd.monitor.
Thanks again.

-- 
But there's no sense crying over every mistake.
You just keep on trying till you run out of cake.
And the Science gets done.
And you make an income.
For the people who are still alive.

-- 
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Data Conversion ?

2009-11-07 Thread John W. Krahn

Nathan Gibbs wrote:

How would I get the length of a string as returned by length () into

a 4 byte unsigned integer in  network byte order


my $length = pack 'N', length $string;



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.   -- Damian Conway

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/