Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re^2: Counting devices types, device sizes and number of devices.
in thread Counting devices types, device sizes and number of devices.

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:

open my $fh, '-|', 'symdev -sid 1234 list -noport -noreserve|find /I " +not visible"'; while (<$fh>) { chomp; my @line = split(/\t/); [...]

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://946121]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-19 02:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found