diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2006-07-31 16:27:22 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2006-07-31 16:27:22 +0000 |
commit | c0c949e7e5385075b541ac0082adce5f5e1fa0ab (patch) | |
tree | 12377b31331663b7b260819286b2fe6c0d2627d2 /usr.sbin | |
parent | e2df8e014a46d19a56030f06e16a62de44f805c4 (diff) |
add missing licence info.
use strict/warning where applicable, and fix relevant warnings.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Getopt.pm | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Getopt.pm b/usr.sbin/pkg_add/OpenBSD/Getopt.pm index e0ef4b11efb..2f67f0f64ac 100644 --- a/usr.sbin/pkg_add/OpenBSD/Getopt.pm +++ b/usr.sbin/pkg_add/OpenBSD/Getopt.pm @@ -1,8 +1,30 @@ +# ex:ts=8 sw=4: +# $OpenBSD: Getopt.pm,v 1.3 2006/07/31 16:27:21 espie Exp $ +# +# Copyright (c) 2006 Marc Espie <espie@openbsd.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +# This is inspired by Getopt::Std, except for the ability to invoke subs +# on options. +# package OpenBSD::Getopt; require Exporter; +use strict; +use warnings; -@ISA = qw(Exporter); -@EXPORT = qw(getopts); +our @ISA = qw(Exporter); +our @EXPORT = qw(getopts); sub handle_option { @@ -12,6 +34,9 @@ sub handle_option if (defined $hash->{$opt} and ref($hash->{$opt}) eq 'CODE') { &{$hash->{$opt}}($params); } else { + no strict "refs"; + no strict "vars"; + ${"opt_$opt"} = $params; push(@EXPORT, "\$opt_$opt"); $hash->{$opt} = $params; @@ -32,7 +57,7 @@ sub getopts($;$) last; } my ($opt, $other) = ($1, $2); - if ($args =~ m/\Q$opt\E(\:)?/) { + if ($args =~ m/\Q$opt\E(\:?)/) { if ($1 eq ':') { if ($other eq '') { die "no argument for option -$opt" unless @ARGV; |