in reply to This should be simple
Regarding your core question, you have multiple problems
Anyway here a demo that works
C:\tmp>perl my $ip = "csteppfw pts/0 2022-06-27 15:53 (192.168.5.100)"; $ip =~ s/.*\((\d+\.\d+\.\d+\.\d+)\).*/\1/; print $ip; __END__ 192.168.5.100 C:\tmp>
But still, simply matching is better.
C:\tmp>perl my $ip = "csteppfw pts/0 2022-06-27 15:53 (192.168.5.100)"; print $1 if $ip =~ /\((\d+\.\d+\.\d+\.\d+)\)/; __END__ 192.168.5.100 C:\tmp>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|