in reply to split question

system will display the command output on the console. You want backticks (documented under Quote and Quote like Operators in perlop) that will capture the output to a variable:

for ( `lspv -l vpath0` ) { print +(split)[4], "\n"; }

but that's going to include the first two lines of the output, which you don't(?) want. So pipe the output of the command to perl:

open my $output, "lspv -l vpath0 |" or die $!; <$output>; # discard first <$output>; # two lines for ( <$output> ) { print +(split)[4], "\n"; }

Replies are listed 'Best First'.
Re^2: split question
by mikejones (Scribe) on Nov 13, 2007 at 18:47 UTC
    Cool. Thank you! But now I have decided to print fields 1 and 4, however I cannot get past this error:
    Use of uninitialized value in concatenation (.) or string at san_relat +ion.plx line 81, <$output> line 3.

    # @vpaths contains vapt0..vpath## for my $vps (@vpaths) { print "\n"; open my $output, "lspv -l $vps |" or die $!; #<$output>; #<$output>; for (<$output>) { next if m[distribution|n/a]i; next unless defined; print Dumper(my ($f1,$f4) = (split)[0, 4]); print "$f1\t$f4\n"; #print +(split)[0],"\n"; #print +(split)[4],"\n"; } print "\n"; #system("odmget -q name=$vps 'CuAt'|grep -p pvid"); } from the Dumper output VAR2 is the problem $VAR1 = 'vpath0:';
    $VAR2 = undef;
    Use of uninitialized value in concatenation (.) or string at san_relat +ion.plx line 81, <$output> line 3. vpath0: $VAR1 = 'lvREPdata10'; $VAR2 = '/db2/REP/sapdata10'; lvREPdata10 /db2/REP/sapdata10