At 5:21 AM +0100 11/28/11, timothy adigun wrote:
>
> 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 prin
>
> > 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?
> Thanks in advance.
>
>
> #!/usr/bi
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
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
according to Programming Perl (p. 98)...
-w = file is writable by effective uid/gid
-s = file has nonzero size (returns size)
-w only tells if the file's permissions allow it to be written to, has
nothing to do with whether or not it already has data.
save the return value of -s and check that v
I don't think the -x tests mean what you think they mean.
>From "perldoc -f -x":
-r File is readable by effective uid/gid.
-w File is writable by effective uid/gid.
-x File is executable by effective uid/gid.
-o File is owned by effective uid.
-R File is
Dave Adams wrote:
> *My Code:*
>
> my $logfile = "logfile_with_content";
> if (-w $logfile) {
> print ("True - file exists but empty");
> }
> if (-s $logfile) {
> print ("True - file exist and has content");
> }
>
> *My Output:*
>
> True - file exists but empty True - file exist and has
>>> "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
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: $dup \n": print "no: $dup \n";
}
-Original Message-
From: david wright [mailt
Actually `dir /B` won't produce anything since dir isn't a real coomand -
it's a shell builtin.
This may help:
c:\>perl -e"for (<*>) { print $_, qq(\n) if(! -x $_ && -B $_ ) }"
Luke
On Thu, 29 Nov 2001, Carl Rogers wrote:
> At 08:09 PM 11/29/2001 +, [EMAIL PROTECTED] wrote:
> >How can I d
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.
>
> If I understand correctly, you want to check
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 certain
directory to see if they AREN
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
28 matches
Mail list logo