Perl Question
Jeffrey Pyne
plug-devel@lists.PLUG.phoenix.az.us
Tue Nov 20 13:07:01 2001
What is going on here? I looked through the Perl Mongers archive and didn't
see anything relevant to my problem. I fruitlessly searched Google, too,
but I'm sure I'm just not using the right keywords. I was hoping maybe
someone here can give me a "Hey, dumb@$$, you forgot to...."
$ cat /home/jpyne/bin/foo
#!/usr/bin/perl
use lib '/home/jpyne/lib';
use Bar;
use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
foo();
bar();
sub foo {
$FOOLOCKFILE = "/var/tmp/foo.lk";
sysopen FOOLOCKFILE, $FOOLOCKFILE, O_WRONLY|O_CREAT|O_EXCL, 0600
or die "Could not create $FOOLOCKFILE: $!\n";
print FOOLOCKFILE "foo";
close FOOLOCKFILE;
}
$ cat /home/jpyne/lib/Bar.pm
#!/usr/bin/perl
use Fcntl qw(O_CREAT O_EXCL O_WRONLY);
package Bar;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(bar);
sub bar {
$BARLOCKFILE = "/var/tmp/bar.lk";
sysopen BARLOCKFILE, $BARLOCKFILE, O_WRONLY|O_CREAT|O_EXCL, 0600
or die "Could not create $BARLOCKFILE: $!\n";
print BARLOCKFILE "bar";
close BARLOCKFILE;
}
$ ./bin/foo
Could not create /var/tmp/bar.lk: No such file or directory
$ ls /var/tmp/*lk
/var/tmp/foo.lk
Why is it that when I call sysopen from MAIN{}, it properly creates a file,
but not when I call it from within my module? I know I'm missing something
stoopid....
TIA
~Jeff
Jeffrey Pyne
UNIX Systems Administrator
WorldatWork
14040 N. Northsight Blvd.
Scottsdale, AZ 85260-3601
Phone: 480-905-5977
Fax: 480-483-8352
Cell: 480-206-3163
Pager: 888-359-2469