in reply to Re: (tye)Re: DATA munging data
in thread DATA munging data
Yes, you said what you were trying to write which is the same as what "vi" saw. But you did not say what Perl and "tail" read back and how it was different.
If you are expecting just plain "tail" to display binary data such as chr(8), then you are mistaken. If you are checking what Perl reads back via a simple print $string; then you'll have the same problem.
You are writing the data with something like: print map {chr} @array; which can be rewritten as: print pack "C*", @array; then you should be extracting the data after you read it with something like: @array= unpack "C*", $string; You said you are using: @array = <DATA>; which will split the data into "lines" based on the value of $/, so this probably isn't working too well. So you either need to set $/ (probably to undef) or use someting like read (or perhaps sysread).
If you have a recent version of Perl, then another alternative is to set $/ to \1 (a reference to the scalar value 1) to tell Perl to read in fixed-length records of 1 byte each, but then you'll still have to unpack the value out of those 1-byte strings so I'd just do this: @array= unpack "C*", do { local($/); <DATA> };
- tye (but my friends call me "Tye")
|
|---|