Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
That way any time I need to open a file, I can just call on this sub instead of doing open(), then flock(), then whatever else every single time.sub myopen { my ($file, $mode, $locktype) = @_; #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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unassociated Filehandles and Subroutines
by JediWizard (Deacon) on Sep 21, 2004 at 15:43 UTC | |
|
Re: Unassociated Filehandles and Subroutines
by ikegami (Patriarch) on Sep 21, 2004 at 15:48 UTC | |
by Zaxo (Archbishop) on Sep 22, 2004 at 01:19 UTC | |
|
Re: Unassociated Filehandles and Subroutines
by rjbs (Pilgrim) on Sep 21, 2004 at 15:36 UTC | |
|
Re: Unassociated Filehandles and Subroutines
by Fletch (Bishop) on Sep 21, 2004 at 15:36 UTC | |
|
Re: Unassociated Filehandles and Subroutines
by BrowserUk (Patriarch) on Sep 21, 2004 at 17:14 UTC | |
|
Re: Unassociated Filehandles and Subroutines
by shemp (Deacon) on Sep 21, 2004 at 15:55 UTC |