I have tried all three methods.... if -s OUT, if -f $filename and if -s 
@arrayname with no evail.????
I did make a test.pl file so that I am just testing whether the file is 
greater than 0 bytes.  Here is the code.
autoflush is turned on.  Is this the correct spot for this?
 
Is it this tedious to test if a file is greater than 0 bytes???? 
I thought perl is supposed to be this great language for UNIX and C 
people???

thank you, 

## Set pragmas

        use strict;

        my $foreigntapes="/usr/local/log/foreign_tapes.log";
        delete $ENV{'IFS'};
        local $ENV{'PATH'} = 
"/usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbin:/bin:/sbin";

        open (OUT, ">$foreigntapes") || die "could not open file:$!";
        my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`;
        $| = 1;
        print OUT "@ftapes";
                if ( -s OUT ) {
                             print "file is greater than 0 bytes \n";
                }






"Wiggins d'Anconia" <[EMAIL PROTECTED]>
06/07/2004 10:36 PM

 
        To:     [EMAIL PROTECTED]
        cc:     [EMAIL PROTECTED]
        Subject:        Re: if -s clause


Please bottom post.

[EMAIL PROTECTED] wrote:
> I originally had
> 
> if ( -s OUT ) {
> 
>     print "file is greater than 0 bytes \n";
>  }
> 
> so is this what I want to use?  Because I just ran it and it is still 
not 
> printing this string.

Well theoretically that might work since the def in the docs indicates a 
filehandle is possible.  I am wondering if maybe it is because your 
output does not contain a new line and is buffered.  One of the gurus 
with internals knowledge would be better suited to answer that. You 
might try turning on autoflush for the handle before printing it, or 
alternatively as I already suggested close the filehandle, which will 
force the flush to occur (and conveniently force you to test the file 
rather than the handle which is my next suggestion).  This is probably 
the copout approach, but to me the easiest least worrisome approach. No 
guesses needed.

> Please excuse my indentation as I cut and pasted it.  My goal is to send 
a mail 
> message using MIME:Lite if the file is greater than 0 bytes else just 
touch a file.
> The reason for opening the RUNFILE is b/c I wanted to create a file to 
verify 
> there the if -s clase produced no output.  In other words, there is no 
data 
> being appended to $foreigntapes variable.
> thank you!
> 
> Here is my code ....
> 
> 
> use strict;
> 
> use MIME::Lite;
> 
> ## Set and edit variables
> 
> my $foreigntapes="/usr/local/log/foreign_tapes.log";
> 
> delete $ENV{'IFS'};
> 
> local $ENV{'PATH'} = "/usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbi
> 
> n:/bin:/sbin";
> 
> #print $ENV{'PATH'},"\n";
> 
> ## Traverse through array and play with data
> 
> open (OUT, ">$foreigntapes") || die "could not open file:$!";
> 
> my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`;
> 
> print OUT "@ftapes";
> 

close OUT or warn "Can't close write handle: $!";

> if ( -s OUT ) {
> 

if (-s $foreigntapes) {

> print "file is greater than 0 bytes \n";
> 
> `ls -la /usr/local/log/foreign_tapes.log`;
> 

Like I said before, what are you trying to accomplish with the above?

> foreach (@ftapes) {
> 
> print $_;
> 
> #`evmlabel -l st_9840_acs_0 -t 9840S -b$_`
> 
> }
> 
> close (OUT);
> 
> } else {
> 
> my $foo="/tmp/ftapes_runfile";
> 
> open (RUNFILE, ">$foo") || die "could not open runfile: $!;"
> 
> }
> 
> close (RUNFILE);
> 
> 

<snip old posts>

http://danconia.org


Reply via email to