use Modern::Perl;
use Modern::Perl;
say ' IP address: 10.10.10.10' =~ /IP\s+address:\s+([^\s]+)/;
say 'IP address: 10.10.10.10' =~ /IP\s+address:\s+([^\s]+)/;
say ' IP address: 10.10.10.10' =~ /^\s*IP\s+address:\s+([^\s]+)/;
say 'IP address: 10.10.10.10' =~ /^\s*IP\s+address:\s+([^\s]+)/;
Output:
10.10.10.10
10.10.10.10
10.10.10.10
10.10.10.10
Update: Ah! hmb104 was referring to using split, not the regex (which isn't attempting to match at the beginning of a line and is fully anchored w/o mentioning the spaces before "IP address:"). |