arg parser
public text v1 · immutableuse strict;
#chdir( 'C:/Documents and Settings/' .
# $ENV{USERNAME} .
# '/My Documents/My Music' ) or die 'CHD';
my %data = parse_toks();
print "$_ -> $data{$_}\n" foreach keys %data;
sub get_data {
die 'ARG';
}
sub parse_toks {
my ($ckey,$nkey,@args);
my @toks = @ARGV or get_data();
foreach my $tok (@toks,'!END') {
($ckey,$nkey) = ($nkey,0);
$nkey = $1 if $tok =~ /^!(\w+.*)/;
push(@args,$ckey,1) if $ckey and $nkey;
push(@args,$ckey,$tok) if $ckey and !$nkey;
}
return @args;
}