home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Ctl.pm < prev    next >
Encoding:
Perl POD Document  |  2004-04-17  |  2.3 KB  |  93 lines

  1. #$Id: Ctl.pm,v 1.2 2004/04/17 17:10:58 sungo Exp $
  2.  
  3. package POE::API::Ctl;
  4.  
  5. use strict;
  6.  
  7. use vars qw($VERSION);
  8. $VERSION = do {my@r=(q$Revision: 1.2 $=~/\d+/g);sprintf"%d."."%04d"x$#r,@r};
  9.  
  10. use POE::Kernel;
  11. use POE::Resource::Controls;
  12.  
  13. use Carp;
  14.  
  15. sub import {
  16.     my $package = caller();
  17.  
  18.     no strict 'refs';
  19.     *{ $package . '::poectl' } = \&poectl;
  20. }
  21.  
  22.  
  23. sub poectl {
  24.     if(scalar @_ == 2) {
  25.         return $poe_kernel->_data_magic_set($_[0] => $_[1]);
  26.     } elsif(scalar @_ == 1) {
  27.         return $poe_kernel->_data_magic_get($_[0]);
  28.     } elsif(scalar @_ == 0) {
  29.         return $poe_kernel->_data_magic_get();
  30.     } else {
  31.         carp "Unexpected number of arguments (".scalar @_.") to poectl()";
  32.         return;
  33.     }
  34. }
  35.  
  36.  
  37. 1;
  38. __END__
  39.  
  40. =head1 NAME
  41.  
  42. POE::API::Ctl -- Switches and Knobs for POE Internals 
  43.  
  44. =head1 SYNOPSIS
  45.  
  46.     use POE::API::Ctl;
  47.  
  48.     my $value = poectl('kernel.id');
  49.  
  50.     my $new_value = poectl('some.name' => 'pie');
  51.  
  52.     my $ctls = poectl();
  53.  
  54. =head1 DESCRIPTION
  55.  
  56. This module provides C<sysctl> like functionality for POE. It exports
  57. into the calling namespace a function named C<poectl>.
  58.  
  59. =head1 FUNCTIONS
  60.  
  61. =head2 poectl
  62.  
  63.     my $value = poectl('kernel.id');
  64.     my $new_value = poectl('some.name' => 'pie');
  65.     my $ctls = poectl();
  66.  
  67. This function is exported into the calling namespace on module load. It
  68. provides the ability to get and set POE control values. All parameters
  69. are optional. If no parameters are given, a hash reference containing a
  70. copy of all POE control entries is returned. If one parameter is given,
  71. the value of that POE control entry is returned. If two parameters are
  72. given, the value of the POE control entry referenced by the first
  73. parameter is set to the contents of the second parameter. In this case,
  74. the new value of the POE control entry is returned. If more than two
  75. parameters are given, an error is thrown and undef is returned.
  76.  
  77. Control entries can be locked by the POE internals. If a write is
  78. attempted to a locked entry, the write will not succeed and the old
  79. value will remain. 
  80.  
  81. =head1 SEE ALSO
  82.  
  83. See L<POE::Kernel> and L<POE::Resource::Controls>.
  84.  
  85. =head1 AUTHORS & COPYRIGHTS
  86.  
  87. Original Author: Matt Cashner (sungo@pobox.com)
  88.  
  89. Please see L<POE> for more information about authors and contributors.
  90.  
  91. =cut
  92.  
  93.