on Wed, 21 Aug 2002 08:02:02 GMT, [EMAIL PROTECTED] (Javeed Sar)
wrote:
> # I want to grep for files with .dsp or .vbp extensions here,
> if the number of files with extension .dsp or .vbp is > 1 i
> should exit saying project exists. or else send mail.
>
> am i doing the right thing?
No you are not. For one, you are not using warnings and strictures.
> @projectFilesExist = <$file\{*.dsp,*.vbp}>;
I wouldn't use glob here. After reading
perlmod File::Glob
and experimenting quite a bit on my win32 system, I don't seem to get
the results I want (most of which has to do with the backslash I
guess ;-).
You don't say what's in $file, so it's a bit hard to comment here.
However, I would opt for a simple (portable) opendir, readdir,
closedir sequence, and grep the results for .dsp and .vbp files.
When you say 'if the number of files with extension .dsp or .vbp
is > 1', do you mean that at least one .dsp and one .vbp file should
exist, or would e.g. two .vbp files also be OK? You can't see the
difference from your code.
The following code checks a directory for the existence of vbp and
dsp files:
#!/usr/bin/perl
use strict;
my $dir = "c:/whatever";
opendir DIR, $dir or die "Cannot open $dir: $!";
my @files = readdir DIR or die "Cannot read files from $dir: $!";
closedir DIR;
my $dspcount = grep { /\.dsp$/i } @files;
my $vbpcount = grep { /\.vbp$/i } @files;
print "There are $dspcount dspfiles and $vbpcount vbpfiles\n";
> if ($projectFilesExist> 1)
This would have been caught by 'use strict;' You never declare this
variable or assign a value to it. Remember, '$foo' has nothing to do
whatsoever with '@foo'.
> $cmd= `sendmail`;
Sending mail is another story. Come back here if you have difficulty
with that.
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]