If the file has been opened by a non-perl process using the native OpenFile or CreateFile APIs, then the easiest (only?) way is to attempt to open the file using the native API OpenFile() with a uStyle parameter of OF_SHARE_EXCLUSIVE. If the file is already open, you will get an error.
If the file has been opened using Perl, then you will always be able to open it as perl use OF_SHARED_DENY_NONE which is fits with the unix standard. See flock for how Perl and unix prevent multiple accesses to files.
You can gain access to the native APIs via Win32::API (and Win32::API::Prototype) or via tyes Win32API::File
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.
| [reply] [Watch: Dir/Any] [d/l] |
thanks a lot for your comprehensive answer. Beyond that i'am glad to see that you aren't resentful regarding my person. Thanks for that too.
greetings, tos
| [reply] [Watch: Dir/Any] |
for unix-systems, there's a command-line tool called lsof (list open files) that provides this
sort of information.
daniel. | [reply] [Watch: Dir/Any] |
not perl, but then neither is lsof -
not as instructive as BrowserUKs answer -
but for raw functionality, ie process, time, file, request &c &c you can not do much better than filemon, from sysinternals sysinternals. on win32. other useful tools abound at the site. it is free.
regards, best wishes,
wufnik
-- in the world of the mules there are no rules --
| [reply] [Watch: Dir/Any] |
(what would be an equivalent way for unix-files?)
On at least Linux and Solaris platforms, use fuser. See Linux::Fuser
--
bm | [reply] [Watch: Dir/Any] [d/l] |