On Fri, Aug 4, 2017 at 6:28 PM, ToddAndMargo <[email protected]> wrote:
> Here is my last attempt:
>
> ip -o -f inet addr show | perl6 -e 'for ( lines ) -> $I { if ( $I ~~ /enp/
> ) { say "Interface <" ~ .words[1] ~ ">\nIP<" ~ .words[3] ~ ">"; } }'
> No such method 'words' for invocant of type 'Any'
> in block <unit> at -e line 1
>
Somewhere above I mentioned that the default for .words was $_. Not $I,
which you have chosen to use. So you'll need to specify the explicit
invocant:
ip -o -f inet addr show | perl6 -e 'for lines() -> $I { if ( $I ~~
/enp/ ) { say "Interface <" ~ $I.words[0] ~ ">\nIP<" ~ $I.words[3] ~ ">"; }
}'
If I swap out your match for a prefix that exists on my system:
pyanfar Z$ ip -o -f inet addr show | perl6 -e 'for lines() -> $I { if (
$I ~~ /wlan/ ) { say "Interface <" ~ $I.words[1] ~ ">\nIP<" ~
$I.words[3].split("/")[0] ~ ">"; } }'
Interface <wlan0>
IP<10.8.201.162>
(For this one, I also removed the CIDR mask from the end.)
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net