Author image Salvador Fandiño García

NAME

Fcntl::Packer - Build packed structures for passing into fcntl.

SYNOPSIS

  use Fcntl::Packer;

  my $p = pack_fcntl_flock { type => F_WRLCK, whence => SEEK_SET,
                             start => 1024, len => 512 };

  fcntl($fh, F_SETLK, $p);

  my $out = pack_fcntl_flock {};
  fcntl($fh, $_GETLK, $out);
  print Dumper unpack_fcntl_flock($out);

DESCRIPTION

POSIX fcntl(2) function accepts some structures that may be difficult to build from Perl in a portable way (for instance, struct flock).

This module implements pairs of methods to pack/unpack these structures.

EXPORT

The following subroutines can be exported from this module:

$str = pack_fcntl_flock \%data;
$hash = unpack_fcntl_flock $data;
$str = pack_f_owner_ex \%data;
$hash = unpack_f_owner_ex $data;

SEE ALSO

fcntl(2), "fcntl" in perlfunc, Fcntl.

There are several modules on CPAN providing high level wrappers for the functionality available through fcntl(2). I.e, IPC::SRLock::Fcntl or File::FcntlLock.

AUTHOR

Salvador Fandiño, <sfandino@yahoo.com>

COPYRIGHT AND LICENSE

Copyright (C) 2013 by Qindel Formación y Servicios S.L.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.