user786 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex in perl
by stevieb (Canon) on Jun 15, 2016 at 00:24 UTC | |
by user786 (Sexton) on Jun 15, 2016 at 03:18 UTC | |
by Anonymous Monk on Jun 15, 2016 at 03:27 UTC | |
by user786 (Sexton) on Jun 15, 2016 at 03:40 UTC | |
by afoken (Chancellor) on Jun 15, 2016 at 05:58 UTC | |
by Anonymous Monk on Jun 15, 2016 at 03:44 UTC | |
by stevieb (Canon) on Jun 15, 2016 at 12:24 UTC | |
|
Re: regex in perl
by BillKSmith (Monsignor) on Jun 15, 2016 at 04:22 UTC | |
by AnomalousMonk (Archbishop) on Jun 15, 2016 at 06:47 UTC | |
by AnomalousMonk (Archbishop) on Jun 16, 2016 at 04:37 UTC | |
by BillKSmith (Monsignor) on Jun 16, 2016 at 16:04 UTC | |
by soonix (Chancellor) on Jun 15, 2016 at 09:21 UTC | |
|
Re: regex in perl
by Anonymous Monk on Jun 15, 2016 at 00:19 UTC |