CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [rpaskudniak] Byte-level pointers similar to C pointers: Edit Log



Laurent_R
Veteran / Moderator

Aug 31, 2013, 2:11 AM


Views: 5211
Re: [rpaskudniak] Byte-level pointers similar to C pointers

Hi,

Using the Informix module would probably be the best.

As a more general solution to read specific bytes, what about opening your variable with a filehandler and using seek/read to read individual byte chunks? I am doing that from time to time on VMS/RMS binary files for which there is no usable module: fetching individual records and looking for specific fields in the records. I do not have an actual example here at home, but this is a quick example under the Perl debugger:


Code
  DB<1> $c = "The quick brown fox jumps over the lazy dog." 

DB<2> open $fh, "<", \$c or die "could not open $c $!"; # opens a reference to the $c variable as a filehandler

DB<3> seek $fh, 10, "00"; # positions the filehandler on the 10th byte

DB<4> read $fh, $out, 10; # reads 10 bytes from position 10

DB<5> print $out;
brown fox



(This post was edited by Laurent_R on Aug 31, 2013, 2:13 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Aug 31, 2013, 2:13 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives