Well it's not impossible and even though it is not really Perl here is how to do it. Presuming by 'edit' you mean double click on the file to open it in an editor.
First you need to understand that under Windows each
file extension is associated with a program. When you double click on a icon
Windows looks at the file extension associated with that icon and uses the
program associated with that extension to open the widget denoted by the icon.
In this way clicking on a txt file opens the file in a text editor but clicking
on a graphic file opens a graphics viewer.
The file associations are set automatically in general but you can set them
in Windows explorer. For example files that end in .txt are associated with
notepad.exe (the actual executable that generates the notepad editor).
When you click on a .txt file windows fires up notepad.exe and passes the
name of the file you double clicked to it. The effect is the same as doing
this on the command line:
c:\>notepad.exe somefile.txt
Knowing this the task is easy. First we write this batch file.
rem this silences this batch file if the rem is removed
rem echo off
rem this executes the perl script
perl c:\myscript.pl
rem this will execute notepad with the double clicked prog
c:\windows\notepad.exe %1
Type this into any text editor like notepad and save it as 'widget.bat'
You can use any name you like but you need the .bat to let Windows know
this is a batch file that can be executed. The %1 gets us the name of
the file that was double clicked in Windows. Now all you do is change the file
association of the .txt files from 'notpad.exe' to 'widget.bat'. Open Windows explorer then View|Options|File Types. This should get you a long list of file types and their associations. Edit the .txt file association to point at your batch file and you are done. Note on some versions of windows the menu location an name is different from above. The menu option is somtimes called Folder Options - you should find it easily.
Now when you double click on a text
file widget.bat will execute which first executes your perl script and then
executes notepad.exe which opens the double clicked text file.
Although this does what you (I think) you said you wanted it is better to run a daemon in the background that monitors writes to files and filters the writes to .txt files as I can edit a text file using any number of methods other than by double clicking on them. This however is very non perl so we might leave this here. It is a simple task so maybe post on a more Windows specific site.
The impossible yesterday, miracles take a little longer...
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|