Chris Knipe ha scritto:
>>> # INTERFACE
>>> RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME
>>> 0 interface_name radio
>>> 00:0C:42:1F:2C:8D yes -63...@18mbps 9Mbps 2h2m38s
>>>
>>> I'm looking for a
>>> foreach my $Line (@Output) {
>>> my ($interface, $radio, $mac, $ap, $signal, $txrate, uptime) =
>>> split(/whatidontknow/, $Line, 7);
>>> }
>>>
>>> Can anyone perhaps help out with the what I don't know bit?? FYI - The
>>> columns should be fixed lengths, if that helps perhaps...
>>>
>>>
>> Hi.
>> Could maybe a simple split(/\s+/ $Line, 7); work?
>>
>
> Almost, but we're not *quite* there yet... It will do though, I think
> (Really just need to get $interface name and $signal)...
>
> foreach my $Line (@Output) {
> my ($tmp, $number, $interface, $radio, $mac, $ap, $signal, $txrate,
> $uptime) = split(/\s+/, $Line, 9);
> print "Number: " . $number . "\n";
> print "Interface: " . $interface . "\n";
> print "Radio: " . $radio . "\n";
> print "MAC: " . $mac . "\n";
> print "AP: " . $ap . "\n";
> print "Signal: " . $signal . "\n";
> print "TX Rate: " . $txrate . "\n";
> print "Uptime: " . $uptime . "\n";
>
> }
>
> Number: 0
> Interface: interface_name
> Radio: radio
> MAC: 00:0C:42:1F:2C:8D
> AP: yes
> Signal: -63dBm...
> TX Rate: 24Mbps
> Uptime:
>
> I'm not sure why I am required to have 9 fields in the split to get the
> values now...
>
> --
> Chris.
>
>
>
>
I am not sure about what's not working for you... It seems to work fine
for me:
my ($number, $interface, $radio, $mac, $ap, $signal, $txrate, $uptime) =
split(/\s+/, $Line, 8);
print "Number: " . $number . "\n";
print "Interface: " . $interface . "\n";
print "Radio: " . $radio . "\n";
print "MAC: " . $mac . "\n";
print "AP: " . $ap . "\n";
print "Signal: " . $signal . "\n";
print "TX Rate: " . $txrate . "\n";
print "Uptime: " . $uptime . "\n";
and 8 should be right, 'cause it's 8 fields you have there..
Could you clarify what you find not working?
Cheers
paolino
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/