>
> was hoping for some add'l assistance. I deleted the bulk of the code out
> b/c I cannot get it to send me the results of the if clause. Any ideas?
> I did verify the file is being appended to and is greater that 0 bytes.
> The if -s on the array is running b/c my else clause is creating the run
> file with a current timestamp???
It is "running", yes, but it is probably attempting to test for a file
that is named the same as the number of elements of the array. That is
my best guess at what Perl is doing, however '-s' takes a
filename/filehandle *NOT* a list.
perldoc -f -s
>
> -rw-r--r-- 1 root eb 7577 Jun 7 17:53 foreign_tapes.log
> -rw-r--r-- 1 root other 0 Jun 7 17:53 ftapes_runfile
>
>
> use strict;
> use warnings;
>
>
> ## 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/sbin:/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";
> if ( -s @ftapes ) {
> print "file is greater than 0 bytes \n";
> `ls -la /usr/local/log/foreign_tapes.log`;
This is a backtick call in void context which is worthless,
non-portable, error prone, slow, etc. If you want information about a
file use the 'stat' built-in.
perldoc -f stat
> foreach (@ftapes) {
This foreach needs to be moved up outside of the file test. Then test
each element of the array.
> print $_;
> #`evmlabel -l st_9840_acs_0 -t 9840S -b$_`
> }
> close (OUT);
A little surprising Perl isn't complaining about the location of this
close, but it truly is an amazing language/interpreter. Since you don't
use OUT after the previous print close it there, which will make the
code much more readable.
> } else {
> my $foo="/tmp/ftapes_runfile";
> open (RUNFILE, ">$foo") || die "could not open runfile:
> $!;"
You open this file and then do nothing with it??
> }
> close (RUNFILE);
>
HTH,
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>