The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Params::Style - Perl module to allow named parameters in perl_style or javaStyle


  use Params::Style;

  my_sub(  FooBar => 1, foo_baz => "bravo");

  sub my_sub
    { my %opt: ParamsStyle = @_;
      print "$opt{foobar} - $opt{foobaz}\n";

or (using a hashref to pass named parameters)

   my_sub(  $toto, $tata, { FooBar => 1, foo_baz => 0 });

  sub my_sub
    { my( $foo, $bar, $opt)= @_;
      my %opt : ParamsStyle( 'JavaStyle')= %$opt;

      print "$opt{FooBar} - $opt{FooBaz}\n";

or (with the functional interface);

  use Params::Style qw( perl_style_params);
  my_sub( $arg, camelCasedOption => 'fooBar', hideousIMHO => 1, badBADBad => 'foo');
  sub my_sub
    { my( $arg, @opts)= @_;
      my %opts= perl_style_params( @opts); 
      # %opts is now:
      # camel_case_option => 'fooBar',
      # hideous_IMHO      => 1,
      # bad_BAD_bad       => 'foo'


Params::Style offers functions to convert named parameters from perl_style to javaStyle nad nostyle and vice-versa


Functional Interface

perl_style_params <params>

Converts the keys in <params> into perl_style keys

<params<gt> can be either an array, an array reference or a hash reference

The return value as the same type as <params>:

  my @params= perl_style_params( myArg1 => 1, myArg2 => 1);
  my %params= perl_style_params( myArg1 => 1, myArg2 => 1);
  my $params= perl_style_params( [myArg1 => 1, myArg2 => 1]); # $params is an array reference
  my $params= perl_style_params( {myArg1 => 1, myArg2 => 1}); # $params is a hash reference
javaStyleParams <params>

Converts the keys of <params> into javaStyle keys

JavaStyleParams <params>

Converts the keys of <params> into JavaStyle keys

nostyleparams <params>

Converts the jeys of <params> into nostyle keys

replace_keys <coderef> <params>

Applies <coderef> to the keys in <params>

The following filters are already defined:


used by JavaStyleParams


used by javaStyleParams


used by perl_style_params


used by nostyleparams


None by default.


Exports perl_style_params, javaStyleParams, JavaStyleParams, nostyleparams and replace_keys

Autotied hash interface

Instead of calling a function it is also possible to use an autotied hash, in which all the keys will be converted to the proper style:

  sub foo
    { my %params: ParamsStyle( 'perl_style')= @_;

The extra parameter to tie is either the name of a style (perl_style, nostyle, javaStyle or JavaStyle) or a code reference, that will be applied to all keys to the hash.

By default (if the style is not given) the style will be perstyle.




Michel Rodriguez, <>


Copyright 2003-2005 by Michel Rodriguez

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.