more useful options | |
PerlMonks |
Re^3: Counting devices types, device sizes and number of devices.by Sewi (Friar) |
on Jan 03, 2012 at 20:03 UTC ( [id://946121]=note: print w/replies, xml ) | Need Help?? |
The my $command = `symdev... doesn't do what you might think. It puts back one line of the symdev output in $command. If you split one line by \n, one item remains (the line without line ending), so your 5,8 are empty/undef because the array simply doesn't have that many items. Try this instead:
The sample above runs the symdev (I'm a little bit unsure about the piping 3-argument-open, try out open my $fh, 'symdev -sid 1234 list -noport -noreserve|find /I "not visible" |'; (notice the final | after the command if it doesn't work) and offers it's output via filehandle $fh. The while loop reads the output line by line presenting every single line in the default variable $_ for one loop run. Read chomp's documentation to see what it does. split also uses the default variable if none specified and returns the columns of the line. I suggested a text hash key instead of the hash tree shown in another answer to your original post because you simple don't need the detailed data in your sample and keeping things simpler might be better for the moment.
In Section
Seekers of Perl Wisdom
|
|