Re: File test operator (race conditions)

2011-11-27 Thread Jim Gibson
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

Re: File test operator (race conditions)

2011-11-27 Thread timothy adigun
> > > 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

Re: File test operator (race conditions)

2011-11-27 Thread masayoshi
- 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

Re: File test operator (race conditions)

2011-11-27 Thread Owen
> 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? >

File test operator (race conditions)

2011-11-27 Thread masayoshi
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

Re: File test failed!

2011-09-16 Thread Magnus Woldrich
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:/

Re: File test failed!

2011-09-16 Thread Shlomi Fish
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

File test failed!

2011-09-16 Thread y...@eisoo.com
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

Re: Inconsistent results from file test (-X) operators

2007-05-16 Thread John W. Krahn
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: > >

Re: Inconsistent results from file test (-X) operators

2007-05-16 Thread Chas Owens
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

Inconsistent results from file test (-X) operators

2007-05-16 Thread R (Chandra) Chandrasekhar
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

File test operator -C in Win32

2006-07-08 Thread Monomachus
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

Fw: File test operator -C in Win32

2006-07-08 Thread Monomachus
--- 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

File test operator -C in Win32

2006-07-08 Thread Monomachus
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>

Re: file test

2006-01-24 Thread Adriano Rodrigues Ferreira
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 $_;

Re: file test

2006-01-24 Thread Adriano Rodrigues Ferreira
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 $_;

Re: file test

2006-01-24 Thread Bob Showalter
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(

Re: file test

2006-01-24 Thread Gerard Robin
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

Re: file test

2006-01-23 Thread Chris Devers
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

file test

2006-01-23 Thread hien
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"); }

Re: File Test Question

2005-11-30 Thread jm
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

RE: File Test Question

2005-11-30 Thread Timothy Johnson
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

Re: File Test Question

2005-11-30 Thread Wiggins d'Anconia
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? > -

File Test Question

2005-11-30 Thread Dave Adams
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

Re: file test doesn't seem to be working

2002-02-05 Thread John Mooney
>>> "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]

Re: file test doesn't seem to be working

2002-02-05 Thread Brett W. McCoy
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

Re: file test doesn't seem to be working

2002-02-05 Thread John Mooney
>>> "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

Re: file test doesn't seem to be working

2002-02-04 Thread Jeff 'japhy' Pinyan
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

Re: file test doesn't seem to be working

2002-02-04 Thread Brett W. McCoy
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

Re: file test doesn't seem to be working

2002-02-04 Thread John W. Krahn
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

Re: file test doesn't seem to be working

2002-02-04 Thread david wright
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

Re: file test doesn't seem to be working

2002-02-04 Thread Jeff 'japhy' Pinyan
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 (".", ".."

Re: file test doesn't seem to be working

2002-02-04 Thread david wright
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

RE: file test doesn't seem to be working

2002-02-04 Thread Timothy Johnson
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

file test doesn't seem to be working

2002-02-04 Thread david wright
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

Re: file test

2001-11-30 Thread Luke Bakken
+, [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

Re: file test

2001-11-29 Thread Brett W. McCoy
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. > &

Re: file test

2001-11-29 Thread Carl Rogers
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

file test

2001-11-29 Thread srogers
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]

Re: file test fails 2nd time thru

2001-10-30 Thread Andrea Holstein
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

file test fails 2nd time thru

2001-10-30 Thread HANSON
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