[boulder.pm] open vs. sysopen

jeff saenz jeff at planetoid.net
Wed Jan 17 19:22:07 CST 2001


i saw an example  in the perl tutorial on flocking that implied you should use
sysopen in combo with flock to write to a locked file.

but I saw another example in the flock reference that used open...

Justin Simoni wrote:

> I'm going to ask a stupid question, but its been said that there aren't any
> stupid questions, just stupid people,
>
> Then again, there's something that says philosophers create proverbs, fools
> repeat them,
>
> saying that,
>
> what is the difference between the two built in Perl functions, open() and
> sysopen() in terms of performance, cross platform usage, etc? To my
> knowledge, open() is Perl's own way of opening thingies, and sysopen() is
> straight from a C library. I know (think) also that sysopen() allows me to
> use default permissions to a file, like this:
>
> sysopen(LIST, "$path/$file_name", O_RDWR|O_CREAT, $file_chmod)or die
> "couldn't open $path/$file_name for reading: $!\n";
>
> I think I started sysopen on a project when I thought open() wouldn't work.
> I think that the problem lay elsewhere, but I still have sysopen() peppered
> in the program. any thoughts on these two functions? My program only runs on
> *nix, although I would like to see NT supported with as little effort as
> possible from me.
>
> Any help would be super appreciated,
>
> thanks,
>
> Justin




More information about the Boulder-pm mailing list