[EMAIL PROTECTED] wrote:
yes I agree I was a little ambiguous... I was in a hurry. sorry.  Anyway
here is my updated code. and here is a sample output:
My goal is to get all F01 which I am but I am having issues capturing all
of these values into my array.  When I run the I get the data I want to see
which is just the F01 column, but when I comment out line 14 and uncomment
line 15 and uncomment line 21 I see no data in the array???
In the end I want the F01 column and the % column.

You only want the two columns, that looks simple enough:

while ( <V4> ) {
    my ( $percent, $f01 ) = /(\d+%).*?(f01\d+)/i or next;
    print "$percent  $f01\n";
    }


 1     2005/01/20 15:39   17   2%  -il-o-b- - - - -  sg F01000
   2     2005/01/20 15:53   14   1%  -il-o-b-----  sg F01001
   3     2005/01/18 09:53    2   0%  -il-o-b-----  sg F01002
   4     2005/02/04 16:41  196 100%  -il-o-b----f  sg F01003
   5     2005/02/05 21:13  305 100%  -il-o-b----f  sg F01004
   6     2005/02/28 22:47  180 100%  -il-o-b-----  sg F01005
  13     2005/02/08 16:07  112 100%  -il-o-b----f  sg F01006
  14     2005/02/09 21:56  122 100%  -il-o-b----f  sg F01007
  15     2005/02/11 10:51  147 100%  -il-o-b----f  sg F01008
  16     2005/02/13 11:35  193 100%  -il-o-b----f  sg F01009
  17     2005/02/14 23:46   79 100%  -il-o-b- - - -f  sg F01010


#!/usr/bin/perl 1> use strict; 2> use warnings; 3> $ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin:/usr/sbin:/usr/local/log); 4> open (V4, "samcmd v4 2>\&1 |" ) || die "unable to open pipe... Broken?

The ampersand is not special in double quoted strings so it doesn't have to be escaped, or you could just use a single quoted string.

$!";
5> my @fa =();
6> my @ha =();
7> my $i =0;
8>        foreach (<V4>) {

Is there any good reason to slurp the entire file into memory?

9>               local $, = "\n";
10>              #print +(split)[6,7], $,;
11>              s <sg> ();
12>              s {\-*} ()g;
13>                s {\w+} ()i;

As has been pointed out, the whitespace after 's' is an error in current versions of Perl however some earlier versions would use whitespace as the delimiter so "s <sg> () ;" would be interpreted as "s/<sg>/()/;".


14> print +(split)[5,6,7], if (m/f01(\d+)/gi )

You are using the match in a boolean context so the /g option makes no sense.


15> #$fa[$i++] = +(split)[5,6,7] if (m/f01(\d+)/gi );

Unlike the print operator, the = operator cannot be used as a function so the + operator is not required. Why are you assigning a list to a scalar and why not just use push() instead of keeping track of the array index?


16>               #print +(split)[4],$,; #% column
17>      }
18> close (V4);

When you open a pipe you should also verify that it closed correctly.

perldoc -f close


19> print "\n";
20> print "Now printing array element 0\t", $fa[0], "\n";
21> #print "Now printing entire array \t", @fa, "\n";
22> print "Now printing array count \t", $#fa, "\n";

The value of $#fa is not the number of elements in the array, for that you want to use the array in scalar context:

print "Now printing array count \t", scalar @fa, "\n";

Or:

print "Now printing array count \t" . @fa . "\n";



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to