bontchev has asked for the wisdom of the Perl Monks concerning the following question:
I have a 4-element array named arr. Each element contains 1 byte of binary data. I need to output these elements in sequence into a file. Currently I am doing this and it works:
print FILE pack ("C", $arr [0]). pack ("C", $arr [1]) . pack ("C", $arr [2]) . pack ("C", $arr [3]);(I have to use pack(), otherwise what is output to the file is the decimal value of the byte in ASCII.)
My question is: is there a better way of doing this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing the elements of an array to a file
by choroba (Cardinal) on Aug 31, 2015 at 15:20 UTC | |
by bontchev (Sexton) on Aug 31, 2015 at 15:46 UTC | |
by Athanasius (Archbishop) on Aug 31, 2015 at 15:56 UTC | |
by AnomalousMonk (Archbishop) on Aug 31, 2015 at 17:22 UTC | |
by choroba (Cardinal) on Aug 31, 2015 at 15:55 UTC |