in reply to Replicate open() and close()
#!/usr/local/bin/perl -w use strict; use subs 'open'; no strict 'refs'; sub open (*;$@) { my $file=shift; my $args=shift; print "My_open\n"; # Do whatever you want CORE::open (*{$file}, $args); } open OUTPUT, ">test2.txt"; print OUTPUT "Hi there.\n"; close OUTPUT; __END__ $ perl override.pl My_open $ cat test2.txt Hi there.
Update: Caveat - the example open in this code is a very naive implementation (handles only two arguments). Beware of dragons.
CU
Robartes-
|
|---|