#!/usr/bin/perl use warnings; use strict; BEGIN { my($path) = $0 =~ m#(.*[/\\])#; push @INC, $path . 'lib'; } use Carp qw(croak); use SvD::GetOpt qw(:constants); my $REG = { HOST => qr/^[\w\._\-]+\.[a-z]{2,}(?::\d+)?$/i, # there are .travel domains now, wtf... IP => qr/^[0-255]\.[0-255]\.[0-255]\.[0-255](?::\d+)?$/, }; my $args = SvD::GetOpt->grab( Format => [ qw/localdir remotedir host/ ], Rules => { remotedir => [ ['r'], OPT_MANDATORY|ARG_NOTNULL, undef ], localdir => [ 'l', OPT_MANDATORY|ARG_NOTNULL|ARG_STR, undef ], host => [ '', OPT_MANDATORY|ARG_NOTNULL, qr/$REG->{HOST}|$REG->{IP}/o ], test => [ '', OPT_OPTIONAL|ARG_NONE, , undef, 'TESTING' ] }, Help => { # Syntax => } ); print "TEST= " . $args->test . "\n"; print "done: " . $args->test . "\n";