in reply to Re: use bytes and length problem
in thread use bytes and length problem

I read up on pack/unpack, and that looked to be a good way to go, however, those are both returning "60" instead of the "208786" value I was hoping for... I'm going to continue to play with the unpack, see what I come up with... any ideas?

Jeff

Replies are listed 'Best First'.
Re: Re: Re: use bytes and length problem
by BrowserUk (Patriarch) on Mar 02, 2003 at 16:28 UTC

    I tested the method on this page and several of those linked from it and it gives me the correct size every time (as compared to the same data dumped to a file in binmode).

    I am pretty certain that the problem is that you are using unpack incorrectly. If you would care to post an example of the how you are using it, and a (small) sample of data that you are using it on, then I am certain that we could sort it the problem out.

    Your reply to pfaut below indicates that you are either trying to use the '/' template character, which will never give you the answers that you require, or you are mixing up the information from different parts of the pack/[and unpack documentation--which would be no surprise as it is probably some of least understandable of the perldocs.


    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.
Re: Re: Re: use bytes and length problem
by pfaut (Priest) on Mar 02, 2003 at 15:51 UTC
Re: Re: Re: use bytes and length problem
by muad33b (Acolyte) on Mar 02, 2003 at 16:00 UTC

    I played around with unpack, and it appears as if the following line from the pack() perldoc (5.6 and 5.8)page is true:

    The length-item is not returned explicitly from unpack.

    Any other ideas? I know I can write this out to a file, but it seems crazy to me to have to do that just to get a proper byte count.

    Jeff