#!C:/perl/bin/perl.exe use strict; use warnings; my $start = '1.2.3.4'; my $end = '1.2.3.6'; my %network = ( '1.2.3.4 links with 1.2.3.5', '1.2.3.5 links with 1.2.3.4', '1.2.3.5 links with 1.2.3.6', '1.2.3.6 links with 1.2.3.5', '1.2.3.6 links with 1.2.3.7', '1.2.3.7 links with 1.2.3.6', '1.2.3.7 links with 1.2.3.4', '1.2.3.4 links with 1.2.3.7', '1.2.3.5 links with 1.2.3.7', '1.2.3.7 links with 1.2.3.5' ); one path is: '1.2.3.4 links with 1.2.3.5' '1.2.3.5 links with 1.2.3.6'