For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2004 > Sysopen fails...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Sysopen fails...
Mauro

2004-04-28, 6:33 am

Hi all, I have a problem using sysopen function.
This is the code:
#!/usr/bin/perl
$filename = "BAD_SPARSE_FILE" ;
sysopen(FH, $filename, O_RDWR|O_CREAT|O_EXCL, 0666) or die "Can't open
$filename: $!" ;
close(FH) ;

And this is the error:
Can't open BAD_SPARSE_FILE: No such file or directory at ./sparse_file line
3.

Why do I get this error?

A file named "BAD_SPARSE_FILE" doesn't exist...

Thank You


Mauro


John W. Krahn

2004-04-28, 6:33 am

Mauro wrote:
>
> Hi all, I have a problem using sysopen function.
> This is the code:
> #!/usr/bin/perl


Add this line to import the O_RDWR, O_CREAT and O_EXCL constants.

use Fcntl;


Of course, if you had also included these two lines then perl would have
pointed out the problem.

use warnings;
use strict;


> $filename = "BAD_SPARSE_FILE" ;
> sysopen(FH, $filename, O_RDWR|O_CREAT|O_EXCL, 0666) or die "Can't open
> $filename: $!" ;
> close(FH) ;
>
> And this is the error:
> Can't open BAD_SPARSE_FILE: No such file or directory at ./sparse_file line
> 3.
>
> Why do I get this error?
>
> A file named "BAD_SPARSE_FILE" doesn't exist...



John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com