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

NAME

Class::Random - Random ancestry for each method call

SYNOPSIS

  package Ridiculous1;
  use Class::Random choose => ['A'],['B'];

  package Ridiculous2;
  use Class::Random choose => qw(C D);

DESCRIPTION

This module allows you to create classes which randomly change their ancestors every time a method is called. This is done simply by using the module, passing a parameter list which dictates the required behaviour. Currently two behaviours are possible, determined by the first argument in the use Class::Random line:

choose

The choose behaviour is given a list of arrays, one of which will be chosen at random to be the calling module's @ISA when a method is called.

shuffle

The shuffle behaviour is given a normal list of class names, which is shuffled each time a method is called.

BUGS

Due to perl's normal sensible strategy of method caching, if the same method is called repeatedly, without any others being called in between, it will always call the same method.

AUTHOR

Peter Haworth <pmh@edison.ioppublishing.com>