@hkoba hkoba.github.io
→
hachiojipm
#79
% ./Greetings.pm hello
Hello world
.pm だけど、コマンドとしても実行できる。
% perl -I. -MGreetings -le 'print Greetings->new(name => "world")->hello'
勿論モジュールとして使える
詳しくは blog 読んで〜
#!/usr/bin/env perl
package Greetings;
use strict;
use warnings;
unless (caller) {
my $cmd = shift
or die "Usage: $0 COMMAND ARGS...\n";
print __PACKAGE__->new(name => "world")->$cmd(@ARGV), "\n";
}
sub new { my $class = shift; bless +{@_}, $class }
sub hello { my $self = shift; join " ", "Hello", $self->{name} }
1;
% ./Greetings.pm <TAB>
% ./Greetings.pm --<TAB>
https://github.com/hkoba/perl-App-oo_modulino_zsh_completion_helper