ZHAO, BING wrote:
Hi,
Hello,
It seems pretty easy to unlink a file from a directory,
but wherever describes unlinking file has no counterpart on create a file.
I did perldoc -q file: got what seemed to be what I
need, then tested my program, no good:
opendir PDB,"SCRATCH" or die "cannot open the SCRATCH dir:$!";
my @GG=grep{!/^./ && !/^../} readdir(PDB); #to store all the file names
in the array @GG
my $NN=scalar (@GG+1);
$filenamie="PDB_$NN.txt";
open LOO,">>SCRATCH/$filenamie" or die "cannot open the
SCRATCH/$filenamie:$!";
sysopen(LOO, "SCRATCH/$filenamie", O_WRONLY|O_TRUNC|O_CREAT) ||
die $!;
sysopen(LOO, "SCRATCH/$filenamie", O_WRONLY|O_TRUNC|O_CREAT, 0666) ||
die $!;
select LOO;
print "linking was successful!";
This didn't work.
Just FYi you don;t have to opendir() a directory to work with files in it.
What was wrong?
use strict;
use warnings;
open my $scratch_fh, '>', "SCRATCH/$filenamie"
or die "can not openSCRATCH/$filenamie: $!";
print $scratch_fh "Hello scratch\n";
close $scatch_fh;
perldoc -f open
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>