Acme-Sub-Parms
view release on metacpan or search on metacpan
lib/Acme/Sub/Parms.pm view on Meta::CPAN
$arg_line = 'my (' . join(",", @var_declarations) . ') = @Acme::Sub::Parms::args{' . join(',',@field_declarations) . '}; ';
}
}
my $unknown_parms_check = '';
unless ($no_validation) {
$unknown_parms_check = 'delete @Acme::Sub::Parms::args{' . join(',',@fields_list) . '}; if (0 < @Acme::Sub::Parms::args) { require Carp; Carp::croak(\'Unexpected parameters passed: \' . join(\', \',@Acme::Sub::Parms::args)); } ';
}
$self->{'bind_block'} = 0;
my $original_block_length = $Acme::Sub::Parms::line_counter - $self->{'line_block_start'};
my $new_block = $args . join(' ',$arg_line, $hard_args, $unknown_parms_check) . "$block_trailing_comment\n";
$new_block =~ s/\n+/\n/gs;
my $new_block_lines = $new_block =~ m/\n/gs;
my $additional_lines = $original_block_length - $new_block_lines;
#warn("Need $additional_lines extra lines\n---\n$new_block---\n");
if ($additional_lines > 0) {
$_ = $new_block . ("\n" x $additional_lines);
} else {
$_ = $new_block;
lib/Acme/Sub/Parms.pm view on Meta::CPAN
} else {
die("Failed to parse BindParms block line $Acme::Sub::Parms::line_counter: $_");
}
} else { # Start of a bind block
if (m/^\s*BindParms\s+:\s+\((\s*#.*$|\s*$)/) {
$self->{'simple_bind'} = 1;
$self->{'bind_entries'} = [];
$self->{'bind_block'} = 1;
$self->{'line_block_start'} = $Acme::Sub::Parms::line_counter;
my $block_head_comment = $2;
$block_head_comment = defined ($block_head_comment) ? $block_head_comment : '';
$block_head_comment =~ s/[\r\n]+$//s;
$_ = $block_head_comment;
#######
# ################################
# # Invokation : $self;
# } elsif (my ($ihead,$ivar,$itail) = m/^(\s*)Invokation\s+:\s+(\S+.*?)\s*;(.*)$/) {
# $_ = $ihead . " my $ivar = shift @_;$itail\n";
lib/Acme/Sub/Parms.pod view on Meta::CPAN
sub a_function {
BindParms : (
my $somevariable : parameter_name [required];
my $anothervariable : another_parameter_name [optional];
)
#...
}
B<IMPORTANT:> The whitespace before and after the ':' in the
'BindParms : (' starting declaration B<IS NOT> optional.
Second, the entire declaration must be on one line: No line breaks in
the middle or other code on the line.
You can make the passed parameter names case insensitive by adding the
':normalize' option on the 'use' line.
Acme::Sub::Parms does not handle anonymous hashes for parameters. It
expects parameters lists to be passed as 'flat' lists. This is due to
performance issues. The additional code required to handle both 'flat'
( run in 0.303 second using v1.01-cache-2.11-cpan-0d8aa00de5b )