- or download this
sub one {
my ($self, $value) = @_;
...
return $self->{two} // 2;
}
# and so on...
- or download this
package Dynamic;
...
1;
__END__
- or download this
use warnings;
use strict;
...
}
printf "sub $_: %d\n", $dyn->$_();
}
- or download this
spek@scelia ~/repos/scripts/perl/dynamically_auto_generate_subs $ perl
+ dyn.pl
...
sub three: 99
sub four: 4
sub five: 5
- or download this
BEGIN {
# Auto generate the stdout() and stderr() methods, and their priva
+te
...
};
}
}