ionally. For example, in the following:
if( -e $file ) {
open(my $fh, '<', $file);
}else{
open(my $fh,'>',$file);
}
two race conditions can occur: an existing file could be deleted by
another process between the '-e $file' test and the open-for-reading,
and a
>
> > From: Owen
> >
> > There is no race condition.
> >
> > And that code demo is correct
>
Actually, there is in a multitasking environment. Please, check subtitle
"File Locking" in perldoc perlopentut.
masayoshi wrote:
> Before calling print method, the file might be deleted by another p
- Original Message -
> From: Owen
>
> There is no race condition.
>
> And that code demo is correct
>
Before calling print method, the file might be deleted by another process
So I reckoned when "File exists" appeared, the file might be deleted. >_>
---
masayoshi & Ayumi Kinoshita
> Hi,I am masayoshi.
> I read the following article.
>
> http://perltraining.com.au/tips/2005-11-24.html
>
>
> A lot of website use the following script to explain file test
> operators,
> But I reckon I should not write it for race conditions.
> Is this right?
>
Hi,I am masayoshi.
I read the following article.
http://perltraining.com.au/tips/2005-11-24.html
A lot of website use the following script to explain file test operators,
But I reckon I should not write it for race conditions.
Is this right?
Thanks in advance.
#!/usr/bin/perl
use strict;
use
On 2011-09-16 17:53, y...@eisoo.com wrote:
I want to test if a file exists or it is a link or not
You test for a regular file with -f.
You test for existance with -e.
You test for symbolic links with -l.
See
perldoc -f -x
for more information.
--
│ Magnus Woldrich
│ m...@japh.se
│ http:/
Hi YYQ,
On Fri, 16 Sep 2011 17:53:25 +0800
"y...@eisoo.com" wrote:
> Hi, All:
>
> I want to test if a file exists or it is a link or not, the code is:
> #!/usr/bin/perl -w
>
> use strict;
> use File::Basename;
> use File::stat;
> use Fcntl ':mode';
>
> my $elfobj = $ARGV[0];
>
> sub str
Hi, All:
I want to test if a file exists or it is a link or not, the code is:
#!/usr/bin/perl -w
use strict;
use File::Basename;
use File::stat;
use Fcntl ':mode';
my $elfobj = $ARGV[0];
sub strtrim ()
{
#.
}
sub copyfile ()
{
#.
}
my @deps = `ldd $elfobj`;
foreach my $li
R (Chandra) Chandrasekhar wrote:
> Dear Folks,
Hello,
> I have encountered inconsistent behaviour with the file test (-X)
> operators. I am using perl, v5.8.8 built for i486-linux-gnu-thread-multi
> on a Kubuntu Feisty system.
>
> I show below my minimal test file:
>
>
On 5/16/07, R (Chandra) Chandrasekhar <[EMAIL PROTECTED]> wrote:
snip
Can anyone please tell me why I get this inconsistent behaviour and how to
overcome it?
snip
It is not inconsistent, you are using file names without the proper
path. If a file or directory exists in the current directory wi
Dear Folks,
I have encountered inconsistent behaviour with the file test (-X) operators. I
am using perl, v5.8.8 built for i486-linux-gnu-thread-multi on a Kubuntu Feisty
system.
I show below my minimal test file:
--- Minimal Test File ---
#!/usr/bin/perl -w
use diagnostics
What does really means -C file test operator on Win32 platform? Creation time
or what?
==
Thanks,
Monomachus
-
This e-mail was sent using Mail.md
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands
--- Forwarded message --
From: Monomachus <[EMAIL PROTECTED]>
To:
Date: 08.07.06 18:12
Subject: File test operator -C in Win32
What does really means -C file test operator on Win32 platform? Creation time
or what?
==
Thanks,
Monomachus
--- End of forwarded m
What does really means -C file test operator on Win32 platform? Creation time
or what?
==
Thanks,
Monomachus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
The operator -e (like the other -X operators) takes a filename or file
handle, and not a glob or file name pattern with wildcards. As others
pointed, you use the builtin glob to do the expansion (either explicitly
or via <>).
Then you might say:
for (glob 'file*') {
print "true\n" if -e $_;
The operator -e (like the other -X operators) takes a filename or file
handle, and not a glob or file name pattern with wildcards. As others
pointed, you use the builtin glob to do the expansion (either explicitly
or via <>).
Then you might say:
for (glob 'file*') {
print "true\n" if -e $_;
hien wrote:
dear all,
i am trying to check if there are any files named file* (e.g.
file_001.txt file1.doc) in my directory.
if( -e "file*" ) { print("true\n"); } # this doesn't work
else { print("false\n"); }
if( -e "m/^file/" ) { print("true\n"); } # this doesn't work either
else { print(
On Mon, Jan 23, 2006 at 09:47:40PM +0100, hien wrote:
> i am trying to check if there are any files named file* (e.g.
> file_001.txt file1.doc) in my directory.
#!/usr/bin/perl
use warnings;
use strict;
my $i = 0;
while () {
if (-e $_) {
print "$_ exists\n";
$i++;
}
}
print "there are $i f
On Mon, 23 Jan 2006, hien wrote:
> i am trying to check if there are any files named file* (e.g.
> file_001.txt file1.doc) in my directory.
perldoc -f glob
--
Chris Devers
DO NOT LEAVE IT IS NOT REAL
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTEC
dear all,
i am trying to check if there are any files named file* (e.g.
file_001.txt file1.doc) in my directory.
if( -e "file*" ) { print("true\n"); } # this doesn't work
else { print("false\n"); }
if( -e "m/^file/" ) { print("true\n"); } # this doesn't work either
else { print("false\n"); }
e) {
> print ("True - file exist and has content");
> }
>
> *My Output:*
>
> True - file exists but empty True - file exist and has content
>
> *My Question:*
>
> Why do both test evaluate to true when the file called
> "logfile_with_content" is 5K in si
e modification time, in days.
-A Same for access time.
-C Same for inode change time (Unix, may differ for other
platforms)
-Original Message-
From: Dave Adams [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 30, 2005 11:16 AM
To: beginners perl
Subject: File Test Quest
t:*
>
> True - file exists but empty True - file exist and has content
>
> *My Question:*
>
> Why do both test evaluate to true when the file called
> "logfile_with_content" is 5K in size? I would expect the second file test
> to only work? Any advice?
>
-
y Question:*
Why do both test evaluate to true when the file called
"logfile_with_content" is 5K in size? I would expect the second file test
to only work? Any advice?
Thanks
>>> "Brett W. McCoy" <[EMAIL PROTECTED]> 2/5/2002 10:35:48 AM >>>
>
>That's just more a matter of style -- I get the willies when subroutines
>modify global values invisibly.
Great advice. thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Tue, 5 Feb 2002, John Mooney wrote:
> Actually, it is not an incorrect way I believe, so much as he is using
> slightly incorrect syntax. From the Nutshell ...
I really meant 'incorrect' in its usage, not the syntax -- he was using it
in a void context.
> ... I think the key is that he was
>>> "Brett W. McCoy" <[EMAIL PROTECTED]> 2/4/2002 9:28:42 PM >>>
>>On Mon, 4 Feb 2002, david wright wrote:
>>
>> i can't use the ternary operator like this? (damn waste if not) thanks.
>>
>> foreach $dup (@array){
>> (-d $dup) ? print "yes: $dup \n": print "no: $dup \n";
>> )
>
>Yes, that i
On Feb 4, Brett W. McCoy said:
>On Mon, 4 Feb 2002, david wright wrote:
>
>> i can't use the ternary operator like this? (damn waste if not) thanks.
>>
>> foreach $dup (@array){
>> (-d $dup) ? print "yes: $dup \n": print "no: $dup \n";
>> )
>
>Yes, that is an incorrect way to use the ?: op
On Mon, 4 Feb 2002, david wright wrote:
> i can't use the ternary operator like this? (damn waste if not) thanks.
>
> foreach $dup (@array){
> (-d $dup) ? print "yes: $dup \n": print "no: $dup \n";
> )
Yes, that is an incorrect way to use the ?: operator -- the operataor is
handed an expr
David Wright wrote:
>
> i am sending @array a directory (i.e. example /usr/dw5) which contains a
> lot of files and folders (directories).
> (i have already checked the value of @array and $dup and they are as
> desired.) What i want to accomplish is: print yes, "$dup (file name)" if
> it's a dir
On Monday, February 4, 2002, at 07:26 PM, Jeff 'japhy' Pinyan wrote:
> On Feb 4, david wright said:
>
>> i am sending @array a directory (i.e. example /usr/dw5) which
>> contains a
>> lot of files and folders (directories).
>
> Be warned that readdir() returns NAMES, not PATHS.
>
> opendir DI
On Feb 4, david wright said:
>i am sending @array a directory (i.e. example /usr/dw5) which contains a
>lot of files and folders (directories).
Be warned that readdir() returns NAMES, not PATHS.
opendir DIR, "/some/dir";
@files = readdir DIR;
closedir DIR;
@files will contain (".", ".."
On Monday, February 4, 2002, at 06:57 PM, Timothy Johnson wrote:
>
> Did you chdir to the directory? Otherwise your script might be
> checking the
> wrong directory.
>
> opendir(DIR,"/mydir");
> @array = readdir(DIR);
> chdir "/mydir";
> foreach $dup (@array){
> (-d $dup) ? print "yes: $d
Original Message-
From: david wright [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 04, 2002 5:51 PM
To: [EMAIL PROTECTED]
Subject: file test doesn't seem to be working
i am sending @array a directory (i.e. example /usr/dw5) which contains a
lot of files and folders (directories).
(i have
i am sending @array a directory (i.e. example /usr/dw5) which contains a
lot of files and folders (directories).
(i have already checked the value of @array and $dup and they are as
desired.) What i want to accomplish is: print yes, "$dup (file name)" if
it's a directory (folder) i am testing i
+, [EMAIL PROTECTED] wrote:
> >How can I do more then one file test for file?
> >
> >I'm trying to test a list of files to see if they're a binary file, that
> >isn't executable.
>
> If I understand correctly, you want to check all files in
On Thu, 29 Nov 2001, Carl Rogers wrote:
> At 08:09 PM 11/29/2001 +, [EMAIL PROTECTED] wrote:
> >How can I do more then one file test for file?
> >
> >I'm trying to test a list of files to see if they're a binary file, that
> >isn't executable.
>
&
At 08:09 PM 11/29/2001 +, [EMAIL PROTECTED] wrote:
>How can I do more then one file test for file?
>
>I'm trying to test a list of files to see if they're a binary file, that
>isn't executable.
If I understand correctly, you want to check all files in a certai
How can I do more then one file test for file?
I'm trying to test a list of files to see if they're a binary file, that isn't
executable.
-Stephanie
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Hanson wrote:
>
> I have a fairly large perl script which optionally runs
> through a few subroutines doing similar things to different
> files. Sorry I can't be more detailed.
> My problem is this: within these subroutines are file tests:
>
> (-e $File) or die
>
> type of stuff.
>
> The first
Hi Gurus!
I have a fairly large perl script which optionally runs
through a few subroutines doing similar things to different
files. Sorry I can't be more detailed.
My problem is this: within these subroutines are file tests:
(-e $File) or die
type of stuff.
The first time through these test
41 matches
Mail list logo