open file failed
- From: zhao_bingfeng@xxxxxxxxxxxxx (Bingfeng Zhao)
- Date: Thu, 26 May 2005 09:13:50 +0800
Good morning, afternoon,
evening for perl enthusiasts of all over the world:)
On RedHat Linux, the perl
complain "Inappropriate ioctl for device" when I use the following code to open
a file:
<CODE>
my $file =
"./abc";
if ( open FN, $file
)
{
print
"Cannot open the file: $!\n";
next;
}
</CODE>
If I use the following code
however, all is OK!
<CODE>
open FH, ">$file" or die
"Cannot open the file: $!\n";
<CODE>
I want to open a few files
in a foreach loop in turn , so I need jump one if I cannot open it rather than
exit.
I modified code and test the FH
as following, perl indicate "Bareword "FH" not allowed while "strict
subs"".
<CODE>
open FH, $name;
if ( not defined FH )
{
print "Cannot open input file: $!\n";
next;
}
</CODE>
if ( not defined FH )
{
print "Cannot open input file: $!\n";
next;
}
</CODE>
I'd like someone tell me what
happen and what file handle(or socket handle, etc) is in perl
really.
BTW, why a DOS-style perl file
cannot run on linux and the bash report ": bad interpreter: No such file or
directory"? It will be OK if I save the file as Unix-style and FTP to
linux.
Another question is what is the
simplest way to replace "\r\n" with "\r" or "\n"?
Thanks.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
- Prev by Date: How to upgrade local module using -MCPAN?
- Next by Date: Re: open file failed
- Previous by thread: How to upgrade local module using -MCPAN?
- Next by thread: Re: open file failed
- Index(es):
Relevant Pages
|