Acme::Hello - Print a greeting message


Acme-Hello documentation Contained in the Acme-Hello distribution.

Index


Code Index:

NAME

Top

Acme::Hello - Print a greeting message

VERSION

Top

This document describes version 0.04 of Acme::Hello.

SYNOPSIS

Top

    use Acme::Hello;    # exports hello() by default
    hello();            # procedure call interface

    my $obj = Acme::Hello->new;
    $obj->hello;        # object-oriented interface

CC0 1.0 Universal

Top

To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Acme-Hello.

This work is published from Taiwan.

http://creativecommons.org/publicdomain/zero/1.0


Acme-Hello documentation Contained in the Acme-Hello distribution.
package Acme::Hello;
$Acme::Hello::VERSION = '0.05';

use strict;
use Acme::Hello::I18N;

use Exporter;
use base 'Exporter';
use vars '@EXPORT';

@EXPORT = 'hello';

sub new {
    my ($class, %args) = @_;
    $class = ref($class) if (ref $class);

    $args{lh} ||= Acme::Hello::I18N->get_handle($args{language})
        or die "Cannot find handle for language: $args{language}.\n";

    return bless(\%args, $class);
}

sub hello {
    my $self = ref($_[0]) ? $_[0] : __PACKAGE__->new;

    print $self->loc("Hello, world!"), "\n";
}

sub lh {
    my $self = shift;
    $self->{lh} = shift if @_;
    return $self->{lh};
}

sub loc {
    my $self = shift;
    return $self->lh->maketext(@_);
}


1;

__END__