eval.in

Paste #139

Perl — Perl 5.16.1, pasted 4 years ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
use strict;

package Greeter;

sub new {
  my ($klass, $greeting) = @_;
  bless { greeting => $greeting }, $klass;
}

sub greet {
  my ($self) = @_;
  print "Hello $self->{greeting}!\n";
}

package main;

my $greeter = Greeter->new("Charlie");
$greeter->greet;

Program Output

Hello Charlie!

OK (0.004 sec real, 0.003 sec wall, 8 MB, 97 syscalls)

Fork