ことはじめ

とりあえずクラスを1個作ってみました。メソッド名の命名規則Javaっぽいのは気にしないでください。

use strict;

package Bug;

sub new {
        my $class = $_[0];
        my $objref = {
                _id => $_[1],
                _type => $_[2],
                _descr => $_[3],
        };
        bless $objref, $class;
        return $objref;
}

sub getID() {
        my ($this) = @_;
        return $this->{_id};
}

sub getType() {
        my ($this) = @_;
        return $this->{_type};
}

sub getDescr() {
        my ($this) = @_;
        return $this->{_descr};
}

sub toString {
        my ($this, @args) = @_;
        print "ID: ".$this->getID()."\n";
        print "TYPE: ".$this->getType()."\n";
        print "DESC: ".$this->getDescr()."\n";
}

package Test;

my $bug1 = new Bug("BUG-001", "BUG", "Syntax Error");
$bug1->toString();
my $bug2 = new Bug("BUG-002", "NaN", "Not Error");
$bug2->toString();

Javaで書くとこんな感じになると思います。

class Bug {
    String id, type, descr;

    public Bug(String id, String type, String descr) {
        this.id = id;
        this.type = type;
        this.descr = descr;
    }

    public String getID() {
        return this.id;
    }

    public String getType() {
        return this.type;
    }

    public String getDescr() {
        return this.descr;
    }

    public String toString() {
        System.out.print("ID: " + this.getID() + "\n");
        System.out.print("TYPE: " + this.getType() + "\n");
        System.out.print("DESC: " + this.getDescr() + "\n");
    }

    public static void main(String[] args) {
        Bug bug1 = new Bug("BUG-001", "BUG", "Syntax Error");
        bug1.toString();
        Bug bug2 = new Bug("BUG-002", "NaN", "Not Error");
        bug2.toString();
    }
}