--- Portfile.orig	2014-09-29 05:15:34.000000000 -0700
+++ Portfile	2014-09-29 05:18:10.000000000 -0700
@@ -46,21 +46,9 @@
   if {${subport} eq "${name}1"} {
     ## change perl exec for all script (how to do it per variant?)
     foreach file [glob -directory ${destroot}${prefix}/bin cif*] {
-        if {[variant_isset perl5_16]} {
-            reinplace "s|/usr/bin/perl|${prefix}/bin/perl5.16|" ${file}
-        } elseif {[variant_isset perl5_18]} {
-            reinplace "s|/usr/bin/perl|${prefix}/bin/perl5.18|" ${file}
-        } elseif {[variant_isset perl5_20]} {
-            reinplace "s|/usr/bin/perl|${prefix}/bin/perl5.20|" ${file}
-        }
-    }
-    if {[variant_isset perl5_16]} {
-        reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5.16|" ${destroot}${prefix}/bin/cif
-    } elseif {[variant_isset perl5_18]} {
-        reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5.18|" ${destroot}${prefix}/bin/cif
-    } elseif {[variant_isset perl5_20]} {
-        reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5.20|" ${destroot}${prefix}/bin/cif
+        reinplace "s|/usr/bin/perl|${prefix}/bin/perl${perl5.major}|" ${file}
     }
+    reinplace "s|/usr/bin/env perl|${prefix}/bin/perl${perl5.major}|" ${destroot}${prefix}/bin/cif
     reinplace "s|/opt/cif|${prefix}|" ${destroot}${prefix}/bin/cif_crontool
     reinplace "s|/opt/cif/etc|${prefix}/etc/cif|" ${destroot}${prefix}/bin/cif_smrt
     xinstall -m 755 -d ${destroot}${prefix}/etc/cif
@@ -186,6 +174,8 @@
 
 subport ${name}1 {
 
+    PortGroup           perl5 1.0
+
     version             1.0.3-FINAL
     master_sites        https://github.com/collectiveintel/cif-v1/releases/download/v${version}/
 
@@ -305,10 +295,6 @@
    https://code.google.com/p/collective-intelligence-framework/wiki/ServerBackup_v1
 "
 
-if {![variant_isset perl5_16] && ![variant_isset perl5_18] && ![variant_isset perl5_20]} {
-    default_variants-append    +perl5_16
-    ## FIXME! have unfound perl dependencies when trying 5.18
-}
 if {![variant_isset pgsql93] && ![variant_isset pgsql92] && ![variant_isset pgsql91] && ![variant_isset pgsql90] && ![variant_isset pgsql84]} {
     default_variants-append    +pgsql93
 }
@@ -317,77 +303,34 @@
 ## http://search.cpan.org/~jkutej/Test-Environment-0.06/    Apache2::RequestRec         UNAUTHORIZED
 ##    Linux::Cpuinfo        Linux only?
 ## FIXME! ZeroMQ deps on v2 (zmq22) or v3
-variant perl5_16 description { use Perl 5.16 bindings } conflicts perl5_18 perl5_20 {
-    ## miss ossp::uuid but pulled off in cpan, maybe replaced by UUID::Tiny
-    ## MISS (from linux): Test::SharedFork, Test::TCP, snort-rule, parse-range
-    ##    https://groups.google.com/forum/#!searchin/ci-framework/ossp$3A$3Auuid/ci-framework/21J3oGwLka4/NvpEESG7pwQJ
-    depends_lib-append port:perl5.16 port:p5.16-digest-sha port:p5.16-digest-sha1 \
-        port:p5.16-log-dispatch port:p5.16-list-moreutils port:p5.16-datetime \
-        port:p5.16-net-ssleay port:p5.16-config-simple \
-        port:p5.16-encode-locale port:p5.16-compress-snappy port:p5.16-net-patricia \
-        port:p5.16-iodef-pb-simple port:p5.16-datetime-format-dateparse \
-        port:p5.16-google-protocolbuffers port:p5.16-class-accessor \
-        port:p5.16-parse-recdescent port:p5.16-mime-lite port:p5.16-dbi \
-        port:p5.16-dbd-pg port:p5.16-class-dbi port:p5.16-zeromq \
-        port:p5.16-lwpx-paranoidagent port:p5.16-net-abuse-utils \
-        port:p5.16-uri port:p5.16-xml-rss port:p5.16-net-dns-match \
-        port:p5.16-regexp-common port:p5.16-lwp-protocol-https \
-        port:p5.16-net-abuse-utils-spamhaus port:p5.16-sys-meminfo \
-        port:p5.16-file-type port:p5.16-libwww-perl port:p5.16-class-trigger \
-        port:p5.16-regexp-common-net-cidr port:p5.16-text-table \
-        port:p5.16-text-aligner port:p5.16-net-dns port:p5.16-net-whois-ip \
-        port:p5.16-regexp-ipv6 port:p5.16-email-address port:p5.16-linux-cpuinfo \
-        port:p5.16-apache2-rest port:p5.16-class-autoaccess \
-        port:p5.16-module-pluggable
-    configure.args-append  --with-perl --with-perl-compat
-    configure.env-append   PERL=${prefix}/bin/perl5.16
-}
-
-variant perl5_18 description { use Perl 5.18 bindings } conflicts perl5_16 perl5_20 {
-    depends_lib-append port:perl5.18 port:p5.18-digest-sha port:p5.18-digest-sha1 \
-        port:p5.18-log-dispatch port:p5.18-list-moreutils port:p5.18-datetime \
-        port:p5.18-net-ssleay port:p5.18-config-simple \
-        port:p5.18-encode-locale port:p5.18-compress-snappy port:p5.18-net-patricia \
-        port:p5.18-iodef-pb-simple port:p5.18-datetime-format-dateparse \
-        port:p5.18-google-protocolbuffers port:p5.18-class-accessor \
-        port:p5.18-parse-recdescent port:p5.18-mime-lite port:p5.18-dbi \
-        port:p5.18-dbd-pg port:p5.18-class-dbi port:p5.18-zeromq \
-        port:p5.18-lwpx-paranoidagent port:p5.18-net-abuse-utils \
-        port:p5.18-uri port:p5.18-xml-rss port:p5.18-net-dns-match \
-        port:p5.18-regexp-common port:p5.18-lwp-protocol-https \
-        port:p5.18-net-abuse-utils-spamhaus port:p5.18-sys-meminfo \
-        port:p5.18-file-type port:p5.18-libwww-perl port:p5.18-class-trigger \
-        port:p5.18-regexp-common-net-cidr port:p5.18-text-table \
-        port:p5.18-text-aligner port:p5.18-net-dns port:p5.18-net-whois-ip \
-        port:p5.18-regexp-ipv6 port:p5.18-email-address port:p5.18-linux-cpuinfo \
-        port:p5.18-apache2-rest port:p5.16-class-autoaccess \
-        port:p5.18-module-pluggable
-    configure.args-append  --with-perl --with-perl-compat
-    configure.env-append   PERL=${prefix}/bin/perl5.18
-}
-
-variant perl5_20 description { use Perl 5.20 bindings } conflicts perl5_16 perl5_18 {
-    depends_lib-append port:perl5.20 port:p5.20-digest-sha port:p5.20-digest-sha1 \
-        port:p5.20-log-dispatch port:p5.20-list-moreutils port:p5.20-datetime \
-        port:p5.20-net-ssleay port:p5.20-config-simple \
-        port:p5.20-encode-locale port:p5.20-compress-snappy port:p5.20-net-patricia \
-        port:p5.20-iodef-pb-simple port:p5.20-datetime-format-dateparse \
-        port:p5.20-google-protocolbuffers port:p5.20-class-accessor \
-        port:p5.20-parse-recdescent port:p5.20-mime-lite port:p5.20-dbi \
-        port:p5.20-dbd-pg port:p5.20-class-dbi port:p5.20-zeromq \
-        port:p5.20-lwpx-paranoidagent port:p5.20-net-abuse-utils \
-        port:p5.20-uri port:p5.20-xml-rss port:p5.20-net-dns-match \
-        port:p5.20-regexp-common port:p5.20-lwp-protocol-https \
-        port:p5.20-net-abuse-utils-spamhaus port:p5.20-sys-meminfo \
-        port:p5.20-file-type port:p5.20-libwww-perl port:p5.20-class-trigger \
-        port:p5.20-regexp-common-net-cidr port:p5.20-text-table \
-        port:p5.20-text-aligner port:p5.20-net-dns port:p5.20-net-whois-ip \
-        port:p5.20-regexp-ipv6 port:p5.20-email-address port:p5.20-linux-cpuinfo \
-        port:p5.20-apache2-rest port:p5.16-class-autoaccess \
-        port:p5.20-module-pluggable
-    configure.args-append  --with-perl --with-perl-compat
-    configure.env-append   PERL=${prefix}/bin/perl5.20
-}
+perl5.branches      5.16 5.18 5.20
+perl5.default_branch 5.16
+perl5.create_variants ${perl5.branches}
+
+## miss ossp::uuid but pulled off in cpan, maybe replaced by UUID::Tiny
+## MISS (from linux): Test::SharedFork, Test::TCP, snort-rule, parse-range
+##    https://groups.google.com/forum/#!searchin/ci-framework/ossp$3A$3Auuid/ci-framework/21J3oGwLka4/NvpEESG7pwQJ
+depends_lib-append port:perl${perl5.major} port:p${perl5.major}-digest-sha port:p${perl5.major}-digest-sha1 \
+    port:p${perl5.major}-log-dispatch port:p${perl5.major}-list-moreutils port:p${perl5.major}-datetime \
+    port:p${perl5.major}-net-ssleay port:p${perl5.major}-config-simple \
+    port:p${perl5.major}-encode-locale port:p${perl5.major}-compress-snappy port:p${perl5.major}-net-patricia \
+    port:p${perl5.major}-iodef-pb-simple port:p${perl5.major}-datetime-format-dateparse \
+    port:p${perl5.major}-google-protocolbuffers port:p${perl5.major}-class-accessor \
+    port:p${perl5.major}-parse-recdescent port:p${perl5.major}-mime-lite port:p${perl5.major}-dbi \
+    port:p${perl5.major}-dbd-pg port:p${perl5.major}-class-dbi port:p${perl5.major}-zeromq \
+    port:p${perl5.major}-lwpx-paranoidagent port:p${perl5.major}-net-abuse-utils \
+    port:p${perl5.major}-uri port:p${perl5.major}-xml-rss port:p${perl5.major}-net-dns-match \
+    port:p${perl5.major}-regexp-common port:p${perl5.major}-lwp-protocol-https \
+    port:p${perl5.major}-net-abuse-utils-spamhaus port:p${perl5.major}-sys-meminfo \
+    port:p${perl5.major}-file-type port:p${perl5.major}-libwww-perl port:p${perl5.major}-class-trigger \
+    port:p${perl5.major}-regexp-common-net-cidr port:p${perl5.major}-text-table \
+    port:p${perl5.major}-text-aligner port:p${perl5.major}-net-dns port:p${perl5.major}-net-whois-ip \
+    port:p${perl5.major}-regexp-ipv6 port:p${perl5.major}-email-address port:p${perl5.major}-linux-cpuinfo \
+    port:p${perl5.major}-apache2-rest port:p${perl5.major}-class-autoaccess \
+    port:p${perl5.major}-module-pluggable
+configure.args-append  --with-perl --with-perl-compat
+configure.env-append   PERL=${prefix}/bin/perl${perl5.major}
+
 
 ## choice: 7 80 81 82 83 84 90 91 92 93
 variant pgsql84 description { use PostgreSQL 8.4 bindings } conflicts pgsql90 pgsql91 pgsql93 pgsql90 {
