<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# -*- perl -*-

use strict;
use warnings;

package MyStrictObject;

use base qw(Net::DBus::Object);
use Net::DBus::Exporter "org.example.MyObject";

sub new {
    my $class = shift;
    my $self = $class-&gt;SUPER::new(@_);

    $self-&gt;{name} = "Joe";
    $self-&gt;{salary} = 100000;

    bless $self, $class;

    return $self;
}

dbus_method("name", [], ["string"]);
sub name {
    my $self = shift;
    return $self-&gt;{name};
}

sub salary {
    my $self = shift;
    return $self-&gt;{salary};
}

package MyFlexibleObject;

use base qw(Net::DBus::Object);
use Net::DBus::Exporter qw(org.example.MyObject);

dbus_no_strict_exports;

sub new {
    my $class = shift;
    my $self = $class-&gt;SUPER::new(@_);

    $self-&gt;{name} = "Joe";
    $self-&gt;{salary} = 100000;

    bless $self, $class;

    return $self;
}

dbus_method("name", [], ["string"]);
sub name {
    my $self = shift;
    return $self-&gt;{name};
}

sub salary {
    my $self = shift;
    return $self-&gt;{salary};
}

package main;

use Net::DBus;
use Net::DBus::Reactor;

my $bus = Net::DBus-&gt;session;
my $service = $bus-&gt;export_service("org.cpan.Net.Bus.test");
my $object1 = MyStrictObject-&gt;new($service, "/org/example/MyStrictObject");
my $object2 = MyFlexibleObject-&gt;new($service, "/org/example/MyFlexibleObject");

Net::DBus::Reactor-&gt;main-&gt;run();
</pre></body></html>