wojtyk has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed monks,

What is the preferable method to do Win32 named pipes? My googling/supersearching hasn't born fruit -- Win32::Pipe seems to be ancient and unmaintained -- Win32API::File has a massive warning at the top of it. As far as I can tell, boilerplate open/write as per the Perl Cookbook only works for UNIX -- and even then it's a mixed bag (since it mirrors normal file I/O convention, opening/writing to a non-existent pipe creates a normal file and appends to it instead of failing with EPIPE)

Replies are listed 'Best First'.
Re: Win32 named pipes
by ikegami (Patriarch) on Feb 23, 2011 at 22:21 UTC

    Win32::Pipe seems to be ancient and unmaintained

    Pipes are ancient. What makes you think it's unmaintained?

    As far as I can tell, boilerplate open/write as per the Perl Cookbook only works for UNIX

    I'd be surprised if it didn't work in Windows too.

    opening/writing to a non-existent pipe creates a normal file

    Not in Windows, since normal files can't start with \\.\pipe.

    Furthermore, using «open '+<'» instead of «open '>'» would avoid that problem everywhere.

Re: Win32 named pipes (Win32API::File)
by tye (Sage) on Feb 23, 2011 at 22:32 UTC
    Win32API::File has a massive warning at the top of it.

    Could you be less vague? I didn't notice a warning at the top of Win32API::File...

    Are you referring to:

    Object Oriented/Tied Handle Interface

    WARNING: this is new code, use at your own risk.

    ? That warning applies to the "Object Oriented/Tied Handle Interface", so don't use that interface if you don't want to. Have you looked up the word massive recently?

    - tye        

Re: Win32 named pipes
by wojtyk (Friar) on Feb 23, 2011 at 22:48 UTC
    What makes you think it's unmaintained?
    Well I can't find many (if any) articles, examples, or blogs of anyone referencing or using this module beyond 2008 (including here on PerlMonks). The copyright is 1996 and the author himself indicates he "may or may not" maintain it. Finally, the CHANGES file in the latest zip appears to illustrate that the last change occurred on July 8, 2002. So it was more of an educated guess.
    That warning applies to the "Object Oriented/Tied Handle Interface"
    Fair enough -- I didn't realize this.

    Though it still doesn't really answer my initial question -- what's the correct way to do it? Just as the 3 argument open is generally preferred over the 2 argument open, there has to be some community-accepted "right way" to do this. Is it via a standard "open("\\.\pipe\...") or via Win32::Pipe or via Win32API::File or via some other method entirely?

      Though it still doesn't really answer my initial question -- what's the correct way to do it?

      Any way that works.

      Just as the 3 argument open is generally preferred over the 2 argument open

      2 arguments doesn't do the same thing as 3 arg open, and doesn't always work.