I have written a function to get a list of ip v6 addresses from a db using sql query. The function works as expected and returns the ip addresses. The output contains the ipv6 addresses. Now, i want to get rid of ::ffff: from all the ip addresses. I want use the following regex /(\d+.\d+.\d+.\d+)/ in the below function to get only ip address in the output. I'm not really sure how to integrate the regex match with the below function.
sub subroutine { my ($self,$vip) = @_; my @ip = (); my $sql_query = $self->{queryObj}->execute( "select machineIP from 'tablename' where frontend=$vip"); my $records = $self->{queryObj}->result(); foreach my $row (@$records) { push @ip, $row->{machineIP}; } return \@ip; }
Function call:
$self->{'get_ip'} = $self->{'queryObj'}->subroutine( 'x.x.x.x' );
output :
::ffff:172.81.139.17
::ffff:198.81.139.21
::ffff:198.81.139.19
In reply to regex in perl by user786
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |