From cebc43339efa6e1ee7f016e3d53aba821ab301f5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 13 Apr 2016 14:21:41 +1200 Subject: First commit Just demonstrating Perl's oddish object-oriented paradigm to a friend of mine --- new-demo | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 new-demo (limited to 'new-demo') diff --git a/new-demo b/new-demo new file mode 100644 index 0000000..57e5e8b --- /dev/null +++ b/new-demo @@ -0,0 +1,40 @@ +#!/usr/bin/env perl + +# Class for the object +package RPG::Wizard; +use strict; +use warnings; +use utf8; +use 5.010; +use Carp; +our $VERSION = 0.1; + +sub new { + my ($class) = @_; + return bless {}, $class; +} + +sub zap { + my ($self) = @_; + say 'Zap!' or croak; + return; +} +1; + +# Demonstration of PACKAGE::new() +package Sanctum::New::Demo; ## no critic (ProhibitMultiplePackages) +use strict; +use warnings; +use utf8; +use 5.010; +use Data::Printer; ## no critic (ProhibitDebuggingModules) +our $VERSION = 0.1; ## no critic (ProhibitReusedNames) + +# Make a wizard object +my $wizard = RPG::Wizard->new(); + +# Print the object +p $wizard; + +# Zap! +$wizard->zap(); -- cgit v1.2.3