Hello sprinter,

Welcome to the Monastery. I am not sure where you got the source code that you have posted because it is a bit different than from the CPAN IPC::SharedMem/source.

To answer your question, no the module does not have a separate pack and unpack method. See source code on the link above or sample below:

sub read { @_ == 3 or croak '$shm->read(POS, SIZE)'; my($self, $pos, $size) = @_; my $buf = ''; if (defined $self->addr) { memread($self->addr, $buf, $pos, $size) or return undef; } else { shmread($self->id, $buf, $pos, $size) or return undef; } $buf; } sub write { @_ == 4 or croak '$shm->write(STRING, POS, SIZE)'; my($self, $str, $pos, $size) = @_; if (defined $self->addr) { return memwrite($self->addr, $str, $pos, $size); } else { return shmwrite($self->id, $str, $pos, $size); } }

From the documentation IPC::SharedMem/methods, it also mentioned:

read ( POS, SIZE ) Read SIZE bytes from the shared memory segment at POS . Returns the st +ring read, or undef if there was an error. The return value becomes t +ainted. See shmread. write ( STRING, POS, SIZE ) Write SIZE bytes to the shared memory segment at POS . Returns true if + successful, or false if there is an error. See shmwrite.

Update: Forgot to add from the Synopsis of the module:

$shm->write(pack("S", 4711), 2, 2);

If you see pack documentation for S:

S An unsigned short value.

So in conclusion it is just the memory position that you read and write. I assume that the copy of the code that you post was from an earlier version but on latest version is clear that the module is using the core pack and unpack of Perl

Hope this helps, unless I did not understand your question.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: IPC::SharedMem::stat using Class::Struct (UPDATED) by thanos1983
in thread IPC::SharedMem::stat using Class::Struct by sprinter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.