use warnings; use subs 'die'; #our own print, but it doesn't override the built-in sub print { CORE::print scalar(localtime),": "; CORE::print(@_); } #our own die, will override the built-in sub die { print "goodbye cruel world\n";} #calls our custom print #notice you have to use &print() notation &print( "hello world\n"); #calls built in print print "goodbye\n"; #calls our overriden die die "hello"; #### Mon May 28 10:41:21 2001: hello world goodbye goodbye cruel world #### #mydie.pm #a package to export a global die, overriding the perl builtin #reference perldoc perlsub package mydie; require Exporter; use vars qw/@ISA @EXPORT/; @ISA = 'Exporter'; @EXPORT_OK = qw/die/; sub import { my $pkg = shift; return unless @_; my $sym = shift; my $where = ($sym =~ s/^GLOBAL_// ? 'CORE::GLOBAL' : caller(0)); $pkg->export($where, $sym, @_); Exporter::import($pkg,@_); } sub die { print "goodbye cruel world\n"; CORE::die $_[0]; } #### #!/usr/local/bin/perl use warnings; use strict; use mydie qw(die); print "hello world\n"; #calls the die exported by mydie.pm die "argh!!!"; #### hello world goodbye cruel world argh!!! at mydie.pm line 20.