On 4/27/05, [EMAIL PROTECTED] <[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.
>
> thank you,
>
> derek
>
> 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?
> $!";
> 5> my @fa =();
> 6> my @ha =();
> 7> my $i =0;
> 8> foreach (<V4>) {
> 9> local $, = "\n";
> 10> #print +(split)[6,7], $,;
> 11> s <sg> ();
> 12> s {\-*} ()g;
> 13> s {\w+} ()i;
> 14> print +(split)[5,6,7], if (m/f01(\d+)/gi )
> 15> #$fa[$i++] = +(split)[5,6,7] if (m/f01(\d+)/gi );
> 16> #print +(split)[4],$,; #% column
> 17> }
> 18> close (V4);
> 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";
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
> "Ing. Branislav
> Gerzo"
> <[EMAIL PROTECTED]> To
> [email protected]
> 04/27/2005 02:46 cc
> AM
> Subject
> Re: REGEXP
>
> [EMAIL PROTECTED] [D], on Tuesday, April 26, 2005 at 17:12
> (-0400) made these points:
>
> D> s/sg//, s/\- {1,}(\w{1,})//,print +(split)[5,6,7], if (m/f01(\d+)/gi )
>
> I think no one replied to you because we don't know what should be
> output.
>
If all you want is the last column, this is a really long way to go about it.
while (<V4>) {
print (split)[7];
print "\n";
}
If you want to do output redierection using the shell, you could just
do it on the command line:
perl -lane 'print $F[7]' `samcmd v4 2>\&1`
See perldoc perlrun for details. In any case, don't mess with the
builtins (i.e. $,). If you want a "\n", print a "\n". Also,
s {\-*} ()g;
is not a valid substitution statement.
s{\-*}()g;
is a valid statement. Notice the lack of spaces. Moving on:
4> open (V4, "samcmd v4 2>\&1 |" ) || die "unable to open pipe...
Broken?$!";
Don't do this. the precedence of || is too high. your code attempts
to open a pipe, and if it can't, then it attempts to open "die..." and
starts throwing exceptions. You want:
open (V4, "samcmd v4 2>\&1 |" ) or die "unable to open pipe... Broken?$!";
This should be enough to get you started. On the whole, though, I'd
seriously recommend that you pick up a copy of a good intro perl book
(_Learning Perl_ springs to mind), and read the FAQ for this group on
how to identify (bad) examples of Perl 4 code, which it seems you've
been looking at.
HTH,
Jay
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>