package # hide from PAUSE warnings; use strict; use Carp; { no strict; $VERSION = '0.07'; } =head1 NAME warnings - warnings.pm emulation for pre-5.6 Perls =head1 VERSION Version 0.07 =head1 SYNOPSIS # enable warnings use warnings; # disable warnings no warnings; =head1 DESCRIPTION This module is a very simple C emulation for Perls before 5.6. Its aim is to allow programs that use this pragma to compile and run under old Perls by providing an API emulation, i.e. the functions work the same, but will not behave exactly like the real module. Under the hood, this module simply uses C<$^W>. Shortcomings: =over =item * this is a module, not a pragma; therefore it isn't lexical; =item * categories are "supported" but won't be used; =item * probably other things.. =back See the documentation of the real C module for more information: L =cut sub import { $^W = 1; } sub unimport { $^W = 0; } =head1 FUNCTIONS =over =item C Returns true if the warnings are enabled, false otherwise. =cut sub enabled { ! ! $^W } =item C Prints the message to C. =cut sub warn { Carp::croak("Usage: warnings::warn([category,] 'message')") unless @_ == 2 || @_ == 1; my $message = pop; Carp::carp($message); } =item C Prints the message to C if warnings are enabled. =cut sub warnif { Carp::croak("Usage: warnings::warnif([category,] 'message')") unless @_ == 2 || @_ == 1; return unless $^W; my $message = pop; Carp::carp($message); } =back =head1 AUTHOR SEbastien Aperghis-Tramoni, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc warnings You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 COPYRIGHT & LICENSE Copyright 2006, 2007, 2008 SEbastien Aperghis-Tramoni, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of warnings