in reply to Re^2: Perl Directive
in thread Perl Directive
You can see this in action by renaming helloworld.exe to helloworld. You will not be able to run it from the Command Prompt, but Perl can still run it with system("helloworld"). If you rename it to helloworld.com, it will still work even though the extension is wrong, because the Kernel does not use the file's name.
Interesting. However, if you rename it helloword.txt and double-click it, Explorer will try to open it in Notepad (by default). So Explorer is still using the old filename mechanism to determine whether it's executable or should open with another program such as Notepad or Perl. But once it determines that it's directly executable (exe, com, or whatever), it then uses another mechanism, different from what Win9x uses. This is actually not surprising, but it's interesting. It's also interesting that Perl's system bypasses the former mechanism, assumes the thing's executable, and jumps straight to the execution system call. One supposes this means that using system in a Perl script to call up a document will not launch the associated application. (One also supposes there's a Win32:: module that will allow you to do that, however, if it's what you want to do. I'm guessing, though.)
It's also useful in certain edge cases. For example, you can rename an .sxw file to .zip, open it as a Compressed Folder, make a minor change to the XML (e.g., removing an unwanted paragraph, which the OOo UI in certain cases won't let you do, e.g., the only paragraph before or after a table), rename it back, doubleclick it, and it opens in OOo again. On *nix you'd just use the command-line zip/unzip to do this, but that's more cumbersome on Windows, so the ability to manipulate the associations is a nice compensation.
Out of curiousity, what if you rename an EXE with a .bat extension and double-click it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Directive
by bunnyman (Hermit) on Dec 14, 2004 at 15:41 UTC | |
by jonadab (Parson) on Dec 15, 2004 at 01:05 UTC |