package Private; use strict; use warnings; use Carp; use vars qw'@ISA @EXPORT $VERSION $PACKAGE'; #============================================================================== # Private.pm - a module to implement extremely simple private subs # this is a 'stub', which will hopefully be expanded upon by # others. #------------------------------------------------------------------------------ # use Private; # sub _my_private_sub { # is_private; # makes this sub package-private # } #------------------------------------------------------------------------------ # (c)2005 Darren Meyer (see LICENSE at end of file) #============================================================================== $VERSION = '0.81'; require Exporter; @ISA = 'Exporter'; @EXPORT = 'is_private'; ## automatically set up the invoking package name on 'use' my $PACKAGE = caller(0); sub is_private() { my @call = caller(1); ## ok if caller of sub that called us was in the invoking package return 1 if $call[0] eq $PACKAGE; ## otherwise, create fatal error ## Package_Name cannot call sub_name (private to Other_Package) confess ( $call[0].' cannot call '.$call[3].' (private to '.$PACKAGE.')'."\n" ); } 1; __END__ =head1 LICENSE This module is licensed under the MIT License, as stated here: Copyright (c)2005 Darren Meyer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut