Re: strawberry's silent con
[email protected] ("E. S.")
| Newsgroups | perl.win32.vanilla |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the tips - I'm glad to know there is at least a way to test for the situation. autodie looks particularly interesting for reasons beyond just this. I think I'll play with that when I get the chance, but for now this issue of CON is only an issue when I'm (rarely) on windows. On Mon, Nov 8, 2010 at 5:13 PM, Jan Dubois <[email protected]> wrote: > On Mon, 08 Nov 2010, E. S. wrote: >> Opening a file named "con" (possibly followed by a dot and some >> extraneous characters) for writing from within perl does not signal an >> error, even though windows doesn't allow it. Instead, the opened file >> handle acts as if everything is OK - you may write to it, close it, >> select it, flush it, wine and dine it. You may even spend an hour >> trying to figure out why, when all of these things happen without >> error, your file doesn't actually exist when your program is finished >> (until you realize what silly things your operating system is doing or >> preventing you from doing). >> >> I'm using the portable version of strawberry out of the box on win >> xp. Another more serpentine language gives a permission error when >> trying to open 'CON.dat' (or any of the various other problematic DOS >> names). This annoyed me enough to post here: Anybody know of a way to >> make perl gag when trying to open the special, un-openable DOS files >> like CON? > > You can use the "-c" file test to check if open() returned a handle to > a regular file, or to a character mode device (like nul, aux, lpt1, com1 > etc). > > If you want to automate this for all open() calls, then check into > subclassing the autodie module to add that check. > > If you don't want to add "use autodie" to your module, either add > -Mautodie to your PERL5OPT environment variable, or add the use > statement to your Perl/site/lib/sitecustomize.pl file. > > Cheers, > -Jan > > >