Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Byte ranges of binary files

by RichardK (Priest)
on Jul 27, 2013 at 15:40 UTC ( #1046663=note: print w/ replies, xml ) Need Help??


in reply to Byte ranges of binary files

What if your range isn't a whole number of $readsz chunks?

I'd do something like this :-

while ($myrange) { $myrange -= read($fh, $buf, min($myrange,$readsz) ) or last; # do stuff }


Comment on Re: Byte ranges of binary files
Download Code
Re^2: Byte ranges of binary files
by PearlsOfWisdom (Initiate) on Jul 27, 2013 at 16:02 UTC
    > What if your range isn't a whole number of $readsz chunks? Shows the use of a second pair of eyes ! Thank you ! ;-) Will go try ....
Re^2: Byte ranges of binary files
by PearlsOfWisdom (Initiate) on Jul 27, 2013 at 22:39 UTC
    Question... doesn't last stop the processing prematurely before the rest of the while block gets a chance to execute ?

      No.

      what do you think the 'or' is doing in that statement?

      hint: Have a look at at 'logical or' in perlop

        Ok, fair enough. But I've tried it and it's not showing me the love in terms of actually working !

        I've tried everything... all the examples here, creating new code based around a for loop, everything but I still can't get it to come up with the right answer.

        By right answer, I mean my code at http://pastebin.com/mz3JiSQV .... coming up with the same answer when asked to calculate for a part of a file that it does when asked to come up with a calculation for a full file (created by using "Dd" to extract from the full file into a second file.

        I'm running out of ideas, totally lost and completely frustrated. Surely its not an impossibility for Perl to accomplish such a simple task ?!?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1046663]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-12-18 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls