I read the documentation for sysopen and the only thing it seems to have that open doesn't is the ability to specify the permissions of newly created files. My old Programming Perl book says to use sysopen instead of open() before using flock() but I see the example at flock uses open(). Is there something else I missed?

In the OP I was attempting to combine two lines of example code from the module documentation that don't work as expected. The documentation says you can tie a filehandle to a win32 handle created by createFile(). I tried that and got an error message about a missing method Win32API::File::TIESCALAR. I found a method called Win32API::File::TIEHANDLE and I was surprised that it wasn't the one called. I was expecting the low level filehandle to be something more than an integer. As you can see in the OP I printed the value of the filehandle and it was an integer.

I wasn't interested in flock since text editors can still open and wipe out the edits my application is making while it is running. I've noticed that when certain types of files are open in Excel I can't overwrite them. I'm trying to get that same low level locking on a Windows Server 2008 platform.

...Usually applications don't use the raw open (or other raw file IO services) directly. Rather they use a library that provides a "friendlier" interface for file IO.

It was my understanding that Win32API::File is a Perl friendly interface to the Win32 API. Saying that people usually don't use raw open is one of those true but irrelevant statements. If raw open is what is needed then people use raw open would be my guess.


In reply to Re^2: opening filehandle with Win32API::File seems to return scalar by Lotus1
in thread opening filehandle with Win32API::File seems to return scalar by Lotus1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.