in reply to Unassociated Filehandles and Subroutines
The simplest modification to your routine is
sub myopen { my ($file, $mode, $locktype) = @_; local *FH; ## Ensure that we get a new GLOB each time #open the file...for the sake of brevity #I'll not include the mode logic here if (open FH, "$file"){ print "Opened $file successfully.\n"; #lock the file #do whatever else needs to be done return *FH; } else { warn "Can't open: $!\n"; } }
|
|---|