If you like to use object oriented features, you can make your task easier.
#!/usr/bin/perl -w
package Vertex;
sub new {
my $class = shift;
my $self = [@_];
bless $self, $class;
}
package Block;
sub new {
my $class = shift;
my $self = [@_];
bless $self, $class;
}
package main;
use strict;
# @blockList has 2 blocks b1 and b2
# Block b1 has 2 vertexes v1 and v2
# Block b2 has 3 vertexes v1, v4 and v3
# Vertex v1 has 3 points (2,3,4)
# Vertex v2 has 3 points (5,6,7) ....
my @blockList;
my $v1 = new Vertex(2,3,4);
my $v2 = new Vertex(5,6,7);
my $v3 = new Vertex(8,9,10);
my $v4 = new Vertex(11,12,15);
my $b1 = new Block($v1,$v2);
my $b2 = new Block($v1,$v4,$v3);
push @blockList,($b1,$b2);
Just a curiosity...
Is this for a game design or graph theory?. There might be something more available on the CPAN for your purpose.
artist
|