
rpaskudniak
User

Sep 1, 2013, 12:29 PM
Post #10 of 10
(5197 views)
|
Re: [Laurent_R] Byte-level pointers similar to C pointers
[In reply to]
|
Can't Post
|
|
Laurent said:
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 Laurent! That's beautiful!! I've written C code to access /dev/mem and /dev/kmem (I sometimes miss my days at AT&T in 30 Knightsbridge) but I had forgotten that I could do this in Perl with a generic block of memory. This opens a whole new vista for me! In other words, Dr. Laurent: You have just crrrreated a MONSTERRRR! If nothing more, it will be great for proof of concept and might just be efficient enough to use in production, using a reference to a shared memory segment to open the file descriptor and building my module around that. Some of the more sniggling details might need some research into structures and Data::Structure::Util (And Hey! That module is/ written in C!) but I have a starting point. And an example to mimic if the fd approach is not efficient enough. Fishmonger, I'm sorry my explanation was misleading. It was meant to convey the spirit of the kind of pointer arithmetic I needed, not to be a lesson in the [publicly known aspects of] Informix internals. And yes, the data will be coming from a TCP port, buffered in such blocks, and written to file, to read back on demand by other utilities. VMS/RMS? Hey, that brings back even older memories! I'm sorry VMS has so fallen out of favor; it was a GREAT OS to work with! But hey, what's a few decades among friends? (No smiley for doddering old fudd. :-{)> ) (Now how do I mark this SOLVED, other than editing the subject line?) -------------------- -- Rasputin Paskudniak (In perpetual pursuit of undomesticated, semi-aquatic avians)
|