PDA

View Full Version : [SOLVED] Perl: sysopen() not working!



computer_freak_8
March 31st, 2009, 02:54 AM
I think all I need is a quick syntax example and I'll be set.

Here's what I've got now:

sysopen(WL, $filepath1, O_RDRW) or die "$filepath cannot be opened.";
And it gives the error:

Argument "O_RDRW" isn't numeric in sysopen at ./perl-fix.pl line 7.

I've looked here (http://perldoc.perl.org/perlopentut.html), as well as a few other places, but I can't seem to get it figured out. Any ideas?

ghostdog74
March 31st, 2009, 03:12 AM
see how they open files here:


perldoc perlopentut

computer_freak_8
March 31st, 2009, 03:38 AM
see how they open files here:


perldoc perlopentut

Yes, that's what I linked to. Any ideas on what's wrong with my code? If I understood that site correctly, my code should work...

unutbu
March 31st, 2009, 04:06 AM
According to http://perldoc.perl.org/functions/sysopen.html
there is a mode called O_RDWR for opening the file in read-write mode. (Note that it is RDWR, not RDRW).

ghostdog74
March 31st, 2009, 04:16 AM
Yes, that's what I linked to. Any ideas on what's wrong with my code? If I understood that site correctly, my code should work...

just use open(), its simpler.


open(FH, "+< $path");

also, as unutbu mentioned, spell them correctly.

computer_freak_8
April 1st, 2009, 12:40 AM
(Note that it is RDWR, not RDRW).
Ah, whoops! I see now. Well, I changed it and:

Argument "O_RDWR" isn't numeric in sysopen at ./perl-fix.pl line 7.

@ghostdog74:

Thanks, that worked!