Listing 1: Caps.pm, the Perl Module that Serves as Our SOAP Endpoint
package Text::Caps;
use strict;
use diagnostics;
# Turn off in production code capitalize expects to
# receive one argument. It returns that argument,
# capitalized, using Perl's built-in
# capitalization (uc) function.
sub capitalize
{
my $self = shift;
my $word = shift;
return uc ($word);
}
# capitalize_array expects to receive a
# list of arguments. The
# subroutine returns a list corresponding to
# the input list, except
# that each element has been capitalized.
sub capitalize_array
{
my $self = shift;
my @words = @_;
return [map {uc $_} @words];
}
1;
Copyright © 1994 - 2018 Linux Journal. All rights reserved.