Assuming the file in question will be created by something external to your Perl script and you just want to wait:
sleep 1 while !-e 'myfile.txt';
Note that !-e means "file doesn't exist". This will keep looping and checking every 1 second forever, and move on only if the relevant file appears.
| [reply] [d/l] |
It is considered bad style to ask in the CB and in SoPW as well without mentioning that, especially if you got good answers in the CB.
Regarding your question: depending on your OS there might be a more elaborate solution, like Win32::ChangeNotify (pointed out by tye++), or dnotify on Linux (ambrus++), I don't know if there is a perl frontend for that.
(Update: clarified first sentence)
| [reply] |
| [reply] |
First sorry to post both in the CB and here, didn't realise it was the wrong approach. Second, I lost internet this avo so couldn't reply immediately. About pausing the perl script, I'm on a linux OS...not sure what this changes for the solution you've posted - many thanks for all your help so far guys.
| [reply] |