# get the current perl version as a string: my $pversion = join(".",map{ord()}split //,$^V); # find paths in @INC that contain or end in that string: my %inc; my $build; for (sort grep m!/\Q$pversion\E(?:/|$)!, @INC) { if ( m!/$pversion$! ) { $inc{$_} = 0; } elsif ( m!(.*?$pversion)/([^/]+)$! ) { $inc{$1} = 1; $build ||= $2; } } for ( keys %inc ) { if ( $inc{$_} == 0 and -d "$_/$build" ) { warn "adding $_/$build to INC array\n"; push @INC, "$_/$build"; } } # now we can "require" modules that have build-specific components # in paths that have just been added.