Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you check if a file is open using Perl?

Tags:

file

perl

Given the name of a file, how can I determine if the file is currently opened or in-use? (I am talking about files rather than Perl file handles.)

Please note that I am looking for a general-purpose Perl solution rather than an operating system-specific one. At a minimum, I would like something that works both on Windows and GNU/Linux-based systems.

like image 900
Sam Avatar asked May 30 '12 11:05

Sam


1 Answers

POSIX does not provide any way to do this. Therefore, no portable solution is possible given the current portable O/S interface available.

You’d have to craft some higher level approach that provides a single point of access for the opening bits. It’s like with lock files.

like image 175
tchrist Avatar answered Oct 01 '22 19:10

tchrist