in reply to Simple query regarding unpack/splice
Unless you're dealing with very large numbers of values, you're working way too hard. pack takes a list of inputs and can process a whole array at a time. So the output to a file can be as simple as:
open OUT, '>:raw', 'data.bin' or die $!;; print OUT pack 'V*', @values;; close OUT;;
And to read them back, unpack can process an unknown length string and produce a list. So that makes it as simple as:
open IN, '<:raw', 'data.bin' or diie $!;; my @values = unpack 'V*', do{ local $/; <IN> };; close IN;;
|
|---|