[Melbourne-pm] Perl crypto code

Scott Penrose scottp at dd.com.au
Fri Sep 22 04:59:15 PDT 2006

On 22/09/2006, at 18:29, Michael Bombardieri wrote:

> Hi everyone,
> I'm posting this email here because there isn't a perth-pm list that I
> know of. I'm a computer science student in Perth, but I used to  
> live in
> Melbourne (Preston).
> I've been playing with cryptography in my spare time and a bit of my
> work is now on Wiretapped.net at
> <http://www.mirrors.wiretapped.net/pub/security/cryptography/ 
> algorithms/mb/>.
> I have 2 questions to ask here:
> 1. What is the general consensus on the state of Perl6? I read that it
> supports / will support strict data types kind of like C, which sounds
> like a great idea. Also, that it will have its own preprocessor. I
> haven't tried out Parrot/Pugs, so forgive me if this is a dumb  
> question.
> Are there people actually using Perl6 at the moment or is it still too
> infantile to do anything useful?

No one is actively using Perl 6 that I know of. Pugs is the closest  
but I am not sure there is any production code. Although you never know.

As for strict types you can do that now in Perl 5 using Attributes.


	my $AnInteger : INTEGER;

Will only be an integer.


	my $LimitedNumber : NUMBER(3..7);

will only allow integers between 3 and 7 (inclusive).


	my $ReallyLimitedName : REGEX(qw/Scott/);

Any string in RealLimitedName must contain Scott

You can be as limited as you like. There is a slight over head though  
- as they are effectively objects.

> 2. How difficult is it to build Perl modules? I've been thinking about
> integrating some crypto code into Perl via a Crypt::bla module. I know
> that some CPAN modules are written in Perl and some in C. Are there  
> any
> good tutorials for writing modules?

Package MyPerlModule;
sub HelloWorld { print "Hello World"; }

That is a module above, but if you want a class instead so you can do OO

Package MyPerlClass;
sub new {
	my ($class) = @_;
	return bless {}, ref($class) || $class;
sub set {
	my ($self, $val) = @_;
	$self->{VAL} = $val;
sub get {
	my ($self) = @_;
	return $self->{VAL};
sub HelloWorld {
	my ($self) = @_;
	print "Hello World - value = " . $self->get . "\n";

now to use it.

use MyPerlClass;
my $thing = MyPerlClass->new();
$thing->set('Your new value');

The hard part about perl modules is the new method you have to write  
- understanding bless, and the use of "ref($class) || $class" - which  
is basically there just to allow inheritance to work and to allow new  
instances from an existing one.

However, you can make it more Java like by adding some helpful  
modules - such as Class::Maker or others (see CPAN).

Good luck with your modules and keep us informed or ask for any more  


More information about the Melbourne-pm mailing list