小编dis*_*ode的帖子

Why does Perl's sysopen report success but $! has an error?

My sysopen fails:

sysopen(DEV, "/dev/ttyS0", O_NONBLOCK|O_RDONLY)
Run Code Online (Sandbox Code Playgroud)

returns 1, which is a success! Then, why does $! have the error "Illegal seek" in it (where it is undef before the call)

before sysopen $!:
after sysopen $!: Illegal seek
Run Code Online (Sandbox Code Playgroud)

EDIT: Here is the full script: (using the actual O_NONBLOCK|O_RDONLY value 2048)

 #!/usr/bin/perl -w
 use Device::SerialPort;
 my $ob;

 $ob = new Device::SerialPort("/dev/ttyS0");

 print $!, "\n";
 $! = 0;

 my $ret = sysopen(DEV, "/dev/ttyS0", 2048);

 print $!, "\n";
 $! = 0;

 print "ret …
Run Code Online (Sandbox Code Playgroud)

perl

3
推荐指数
1
解决办法
1453
查看次数

标签 统计

perl ×1