Options.pm (PDL-2.082) | : | Options.pm (PDL-2.083) | ||
---|---|---|---|---|
skipping to change at line 15 | skipping to change at line 15 | |||
PDL::Options - simplifies option passing by hash in PerlDL | PDL::Options - simplifies option passing by hash in PerlDL | |||
=head1 SYNOPSIS | =head1 SYNOPSIS | |||
use PDL::Options; | use PDL::Options; | |||
%hash = parse( \%defaults, \%user_options); | %hash = parse( \%defaults, \%user_options); | |||
use PDL::Options (); | use PDL::Options (); | |||
$opt = new PDL::Options; | $opt = PDL::Options->new; | |||
$opt = new PDL::Options ( \%defaults ); | $opt = PDL::Options->new( \%defaults ); | |||
$opt->defaults ( \%defaults ); | $opt->defaults ( \%defaults ); | |||
$opt->synonyms ( { 'COLOR' => 'COLOUR' } ); | $opt->synonyms ( { 'COLOR' => 'COLOUR' } ); | |||
$hashref = $opt->defaults; | $hashref = $opt->defaults; | |||
$opt->options ( \%user_options ); | $opt->options ( \%user_options ); | |||
$hashref = $opt->options; | $hashref = $opt->options; | |||
skipping to change at line 129 | skipping to change at line 129 | |||
my $casechk = shift; | my $casechk = shift; | |||
my $defaults = shift; | my $defaults = shift; | |||
croak ("First argument is not a hash reference") | croak ("First argument is not a hash reference") | |||
unless ref($defaults) eq "HASH"; | unless ref($defaults) eq "HASH"; | |||
my $user = shift; | my $user = shift; | |||
croak ("Second argument is not a hash reference") | croak ("Second argument is not a hash reference") | |||
unless ref($user) eq "HASH"; | unless ref($user) eq "HASH"; | |||
# Create new object | # Create new object | |||
my $opt = new PDL::Options ( $defaults ); | my $opt = PDL::Options->new( $defaults ); | |||
# Set up default behaviour | # Set up default behaviour | |||
$opt->minmatch(1); | $opt->minmatch(1); | |||
$opt->casesens($casechk); | $opt->casesens($casechk); | |||
$opt->synonyms( \%DEF_SYNS ); | $opt->synonyms( \%DEF_SYNS ); | |||
# Process the options | # Process the options | |||
my $optref = $opt->options( $user ); | my $optref = $opt->options( $user ); | |||
return %$optref; | return %$optref; | |||
skipping to change at line 927 | skipping to change at line 927 | |||
COLOUR => 'blue' | COLOUR => 'blue' | |||
) | ) | |||
=head1 Object oriented | =head1 Object oriented | |||
The following example will try to show the main points: | The following example will try to show the main points: | |||
use PDL::Options (); | use PDL::Options (); | |||
# Create new object and supply defaults | # Create new object and supply defaults | |||
$opt = new PDL::Options( { Colour => 'red', | $opt = PDL::Options->new( { Colour => 'red', | |||
LineStyle => 'dashed', | LineStyle => 'dashed', | |||
LineWidth => 1 | LineWidth => 1 | |||
} | } | |||
); | ); | |||
# Create synonyms | # Create synonyms | |||
$opt->synonyms( { Color => 'Colour' } ); | $opt->synonyms( { Color => 'Colour' } ); | |||
# Create translation dictionary | # Create translation dictionary | |||
$opt->translation( { Colour => { | $opt->translation( { Colour => { | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |