<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en"><title type="text">xenoterracide</title><link rel="alternate" type="text/html" href="http://www.xenoterracide.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/xenoterracide" /><subtitle type="html">Caleb Cushing  ( xenoterracide )'s Blog</subtitle><author><name>Caleb Cushing</name><email>noreply@blogger.com</email><uri>https://profiles.google.com/109135658789518811986</uri></author><updated>2012-05-30T08:04:06+00:00</updated><generator uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">181</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">5</openSearch:itemsPerPage><feedburner:info uri="xenoterracide" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><id>tag:blogger.com,1999:blog-2238114716501996649</id><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/3.0/" /><feedburner:emailServiceId>xenoterracide</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry><title type="text">Perl Core Syntax Wishlist: Class support</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/xenoterracide/~3/Owe8Cx7kaHo/perl-core-syntax-wishlist-class-support.html" /><category term="perl syntax wishlist" /><category term="perl" /><category term="ironman" /><author><name>Caleb Cushing</name><email>noreply@blogger.com</email><uri>https://profiles.google.com/109135658789518811986</uri></author><updated>2012-05-28T03:00:01-07:00</updated><id>tag:blogger.com,1999:blog-2238114716501996649.post-4692901805474900840</id><content type="html">I would like to see the &lt;code&gt;class&lt;/code&gt; keyword become part of Perl, but unlike some I don't want it simply because it's nicer syntax. I'd like it to behave differently from &lt;code&gt;package&lt;/code&gt;.
I'd basically like to see this
&lt;script src="https://gist.github.com/2632369.js"&gt; &lt;/script&gt;
&lt;noscript&gt;
&lt;pre&gt;
&lt;code&gt;
class MyClass {
   method foo { return $self-&gt;{foo} }
   method info { return load_class('Class::Info')-&gt;new }
}
&lt;/code&gt;
&lt;/pre&gt;
to be the equivalent of
&lt;pre&gt;
&lt;code&gt;
{
   use strict;
   use warnings;
   use utf8; # so our class can be named with utf8
   package MyClass {
      use namespace::autoclean;
      use Scalar::Util qw( blessed );
      # use Class::Load qw( load_class );
      # or similar for a feature that I'm hoping will be in Class::Load in the future
      # for now I'll show with require

      sub new { # or something better, point is that there's a default simple constructor
          my $class = shift;
          my $self  = ref $_[0] eq 'HASH' ? $_[0] : { @_ };

          bless $self, $class;
          return $self;
      }
      sub foo { my $self = shift; return $self-&gt;{foo} }

      sub info { #doesn't actually do what I'm really suggesting
          my $self = shift;
          require Class::Info;
          return  Class::Info-&gt;new;
      }
   }
}

MyClass-&gt;new-&gt;foo;
&lt;/code&gt;
&lt;/pre&gt;
&lt;/noscript&gt;
I'm sure smarter people than I could think of a few more things that might be nice to have by default in all classes. I would like to note that method signatures is not that big of a deal to me, unless of course you want to give me named variables in the signature besides just auto shifting off self, e.g. &lt;code&gt;method foo ( $bar  ) { return $self-&gt;{foo} if $bar }&lt;code&gt;&lt;div class="blogger-post-footer"&gt;&lt;br /&gt;--&lt;br /&gt;
This &lt;span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type"&gt;work&lt;/span&gt; by &lt;a xmlns:cc="http://creativecommons.org/ns#" href="http://www.xenoterracide.com" property="cc:attributionName" rel="cc:attributionURL"&gt;Caleb Cushing&lt;/a&gt; is licensed under a &lt;a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2238114716501996649-4692901805474900840?l=www.xenoterracide.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W4D3hu_ydPddF1bNX_bFwW76B3w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W4D3hu_ydPddF1bNX_bFwW76B3w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W4D3hu_ydPddF1bNX_bFwW76B3w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W4D3hu_ydPddF1bNX_bFwW76B3w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/xenoterracide/~4/Owe8Cx7kaHo" height="1" width="1"/&gt;</content><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-28T06:00:01.808-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total><feedburner:origLink>http://www.xenoterracide.com/2012/05/perl-core-syntax-wishlist-class-support.html</feedburner:origLink></entry><entry><title type="text">Better Exceptions with Exception::Base</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/xenoterracide/~3/CwMMlkvTMsk/better-exceptions-with-exceptionbase.html" /><category term="perl" /><category term="ironman" /><category term="exceptions" /><author><name>Caleb Cushing</name><email>noreply@blogger.com</email><uri>https://profiles.google.com/109135658789518811986</uri></author><updated>2012-05-21T03:00:05-07:00</updated><id>tag:blogger.com,1999:blog-2238114716501996649.post-5624799037706500048</id><content type="html">So I've done some &lt;a href="http://www.xenoterracide.com/2012/05/perl-core-syntax-wishlist-die-should.html"&gt;complaining&lt;/a&gt; and &lt;a href="http://www.xenoterracide.com/2012/05/perl-core-syntax-wishlist-exception.html"&gt;explaining&lt;/a&gt; about what I'd like to see in regards to Exceptions in Perl. I Mostly explained what I wanted for catching Exceptions, and a little on throwing Exception objects, but not really how those objects should behave. I've looked at and tried various exception modules, including &lt;a href="http://perldoc.perl.org/Carp.html"&gt;croak, confess&lt;/a&gt;, and &lt;a href="https://metacpan.org/module/Throwable"&gt;Throwable&lt;/a&gt;.

I basically spent time one day reading the manuals of most of the exception objects on CPAN. Most of them didn't allow me to easily for the exceptions I needed (meaning they required more work than I thought I should do for one or two exceptions ). Among these modules I found &lt;a href="https://metacpan.org/module/Exception::Base"&gt;Exception::Base&lt;/a&gt;, which appears to do everything I need (though I still wish for something like it in core, with shinier syntax).

Of course wee need to be able to throw simple Exceptions, preferably ones that can stringify, and are easily matched in a switch or if statement. &lt;a href="https://metacpan.org/module/Exception::Base"&gt;Exception::Base&lt;/a&gt; can do all of that, and it even boolifies to true.
&lt;script src="https://gist.github.com/2657327.js"&gt; &lt;/script&gt;
&lt;noscript&gt;
&lt;pre&gt;
&lt;code&gt;
use Try::Tiny;
use Exception::Base;

try {
    if ( 0 ) {
        Exception::Base-&gt;throw( message =&gt; 'this sucks', value =&gt; 0 );
    }

    if ( 1 ) {
        Exception::Base-&gt;throw( message =&gt; 'this really sucks', value =&gt; 1 );
    }
}
catch {
    given ( $_ ) {
        when ( $_ == 0 ) {
            say $_;
        }
        when ( $_ == 1 ) {
            say $_;
        }
    }
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;/noscript&gt;

A really big thing I wanted was a class I could easily add attributes to without writing a whole new package/pm and subclassing it there. I wanted this because I really wanted to be able to have 2 kinds of messages, one for programmers, and one for users, but truthfully I only had one class where I needed this flexibility (at the time). It is also occasionally useful to have attributes that describe something, e.g. would be really useful in moose attribute exceptions, to be able to have an object where you could catch the exception and get the attribute name without parsing. Fortunately &lt;a href="https://metacpan.org/module/Exception::Base"&gt;Exception::Base&lt;/a&gt; can do this too.
&lt;script src="https://gist.github.com/2657880.js"&gt; &lt;/script&gt;
&lt;noscript&gt;
&lt;pre&gt;
&lt;code&gt;

use 5.014;
use warnings;

use Try::Tiny;
use Exception::Base (
    'My::Exception' =&gt; {
        has =&gt; [ qw( usermsg logmsg attr ) ],
        string_attributes =&gt; [ qw( usermsg logmsg ) ],
    },
);

try {
        My::Exception-&gt;throw(
            value =&gt; 1,
            attr    =&gt; 'bad',
            logmsg  =&gt; 'really obscure and technical',
            usermsg =&gt; 'this message is useless'
        );
}
catch {
    warn $_;
    say $_-&gt;usermsg;    

    say 'this is really bad' if $_-&gt;attr eq 'bad';
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;/noscript&gt;

You'll notice if you run this script that in the warn, both &lt;code&gt;usermsg&lt;/code&gt; and &lt;code&gt;logmsg&lt;/code&gt; are printed because they are both &lt;code&gt;string_attributes&lt;/code&gt;. You'll also notice that &lt;code&gt;attr&lt;/code&gt; isn't printed at all, but that we can look at it directly to make other decisions.

&lt;a href="https://metacpan.org/module/Exception::Base"&gt;Exception::Base&lt;/a&gt; has other features such as setting the &lt;code&gt;verbosity&lt;/code&gt; so you can go from a &lt;code&gt;croak&lt;/code&gt; level message to a full stacktrace. It also allows you to &lt;code&gt;ignore_package&lt;/code&gt;s so that the exception does not appear to be thrown from that package. This is similar to &lt;code&gt;@CARP_NOT&lt;/code&gt;.&lt;div class="blogger-post-footer"&gt;&lt;br /&gt;--&lt;br /&gt;
This &lt;span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type"&gt;work&lt;/span&gt; by &lt;a xmlns:cc="http://creativecommons.org/ns#" href="http://www.xenoterracide.com" property="cc:attributionName" rel="cc:attributionURL"&gt;Caleb Cushing&lt;/a&gt; is licensed under a &lt;a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2238114716501996649-5624799037706500048?l=www.xenoterracide.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2E6HZDzDFTSpWuCQQ0F2l4HKBEM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2E6HZDzDFTSpWuCQQ0F2l4HKBEM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2E6HZDzDFTSpWuCQQ0F2l4HKBEM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2E6HZDzDFTSpWuCQQ0F2l4HKBEM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/xenoterracide/~4/CwMMlkvTMsk" height="1" width="1"/&gt;</content><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-21T06:00:05.789-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.xenoterracide.com/2012/05/better-exceptions-with-exceptionbase.html</feedburner:origLink></entry><entry><title type="text">Perl Core Syntax Wishlist: die should die</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/xenoterracide/~3/dkh-gbsJz7U/perl-core-syntax-wishlist-die-should.html" /><category term="perl syntax wishlist" /><category term="perl" /><category term="ironman" /><category term="exceptions" /><author><name>Caleb Cushing</name><email>noreply@blogger.com</email><uri>https://profiles.google.com/109135658789518811986</uri></author><updated>2012-05-14T03:00:05-07:00</updated><id>tag:blogger.com,1999:blog-2238114716501996649.post-2373792075103611302</id><content type="html">I hate &lt;a href="http://perldoc.perl.org/functions/die.html"&gt;&lt;code&gt;die&lt;/code&gt;&lt;/a&gt; it is, in my humble opinion, one of the worst parts of perl. I really wish it would be deprecated, and removed, or at least replaced with something that would tell you were the code that was die-ing was being called. Replace its implementation with that of &lt;a href="http://perldoc.perl.org/Carp.html"&gt;Carp's&lt;/a&gt; &lt;code&gt;croak&lt;/code&gt; or &lt;code&gt;confess&lt;/code&gt; and I'd be happy. Better yet, let's just get &lt;a href="http://www.xenoterracide.com/2012/05/perl-core-syntax-wishlist-exception.html"&gt;real exception support&lt;/a&gt; and deprecate die (even if that's never removed deprecation just make that real big on its pod). If you're using &lt;code&gt;die&lt;/code&gt; please stop and &lt;a href="http://perldoc.perl.org/Carp.html"&gt;use Carp&lt;/a&gt;, anyone using your module will thank (and by thank I mean not curse) you later.&lt;div class="blogger-post-footer"&gt;&lt;br /&gt;--&lt;br /&gt;
This &lt;span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type"&gt;work&lt;/span&gt; by &lt;a xmlns:cc="http://creativecommons.org/ns#" href="http://www.xenoterracide.com" property="cc:attributionName" rel="cc:attributionURL"&gt;Caleb Cushing&lt;/a&gt; is licensed under a &lt;a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2238114716501996649-2373792075103611302?l=www.xenoterracide.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/C7yuWiZ8csbmcI8UhxDp6WpmR2M/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C7yuWiZ8csbmcI8UhxDp6WpmR2M/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/C7yuWiZ8csbmcI8UhxDp6WpmR2M/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C7yuWiZ8csbmcI8UhxDp6WpmR2M/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/xenoterracide/~4/dkh-gbsJz7U" height="1" width="1"/&gt;</content><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-14T06:00:05.121-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.xenoterracide.com/2012/05/perl-core-syntax-wishlist-die-should.html</feedburner:origLink></entry><entry><title type="text">Perl Core Syntax Wishlist: an Exception Stack</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/xenoterracide/~3/RWXl2pJ7Co0/perl-core-syntax-wishlist-exception.html" /><category term="perl syntax wishlist" /><category term="perl" /><category term="ironman" /><category term="exceptions" /><author><name>Caleb Cushing</name><email>noreply@blogger.com</email><uri>https://profiles.google.com/109135658789518811986</uri></author><updated>2012-05-10T23:53:31-07:00</updated><id>tag:blogger.com,1999:blog-2238114716501996649.post-4482969563793757513</id><content type="html">I have come to wish many things were part of&amp;nbsp;&lt;a href="http://perldoc.perl.org/perlsyn.html"&gt;Perl syntax&lt;/a&gt;&amp;nbsp;that are not, and no using external modules is not enough for me. I think it's time Perl got the features as part of the language itself (and yes I suppose I could settle for feature.pm, and no I'm probably not going to write them myself, I'm not smart enough yet). The first of these is a proper exception stack. I want to be able to write:
&lt;script src="https://gist.github.com/2632082.js"&gt; &lt;/script&gt;
&lt;noscript&gt;
&lt;pre&gt;
&lt;code&gt;
use 5.018;
use warnings;

sub foo {
    throw Exception-&gt;new( 'message' );
}

try {
    foo();
}
catch ( 'Exception' ) {
     say "$_"; # object stringifies
}
catch ( 'Exception::Other' ) {
     say $_-&gt;message #also has an accessor
}
finally {
     ...
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;/noscript&gt;
I think we need &lt;code&gt;throw&lt;/code&gt;, &lt;code&gt;try&lt;/code&gt;, &lt;code&gt;catch&lt;/code&gt;, and &lt;code&gt;finally&lt;/code&gt; keywords.  And no I don't think it makes sense to have &lt;code&gt;Object-&gt;throw&lt;/code&gt;. In fact I think this &lt;a href="http://www.perl6.org/archive/rfc/63.html"&gt;Original Perl 6 Syntax Proposal&lt;/a&gt; reads like just what we need in Perl 5. Unfortunately I think &lt;a href="http://perl6advent.wordpress.com/2011/12/15/day-15-something-exceptional/"&gt;this&lt;/a&gt; is what we are getting in Perl 6, which IMO is not as nice.&lt;div class="blogger-post-footer"&gt;&lt;br /&gt;--&lt;br /&gt;
This &lt;span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type"&gt;work&lt;/span&gt; by &lt;a xmlns:cc="http://creativecommons.org/ns#" href="http://www.xenoterracide.com" property="cc:attributionName" rel="cc:attributionURL"&gt;Caleb Cushing&lt;/a&gt; is licensed under a &lt;a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2238114716501996649-4482969563793757513?l=www.xenoterracide.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/fR5DJZG0iaPmrZpPWwR5xcQlZj0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fR5DJZG0iaPmrZpPWwR5xcQlZj0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/fR5DJZG0iaPmrZpPWwR5xcQlZj0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fR5DJZG0iaPmrZpPWwR5xcQlZj0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/xenoterracide/~4/RWXl2pJ7Co0" height="1" width="1"/&gt;</content><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-11T02:53:31.728-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.xenoterracide.com/2012/05/perl-core-syntax-wishlist-exception.html</feedburner:origLink></entry><entry><title type="text">Adventures with SOAP using Perl: Part 2 ( SOAP::Data::Builder )</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/xenoterracide/~3/NR132PUfvOs/adventures-with-soap-using-perl-part-2.html" /><category term="SOAP::Lite" /><category term="SOAP::Data::Builder" /><category term="SOAP" /><category term="perl" /><category term="ironman" /><author><name>Caleb Cushing</name><email>noreply@blogger.com</email><uri>https://profiles.google.com/109135658789518811986</uri></author><updated>2012-03-11T14:10:01-07:00</updated><id>tag:blogger.com,1999:blog-2238114716501996649.post-8517080194393734898</id><content type="html">&lt;p&gt;
Start by reading the first 2 parts :
&lt;ol style="list-style: none;"&gt;
  &lt;li&gt;Part 0 &lt;a href="http://www.xenoterracide.com/2011/10/adventures-with-soap-using-perl-part-0.html"&gt;Prelude (setup server.pl)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Part 1 &lt;a href="http://www.xenoterracide.com/2011/10/adventures-with-soap-using-perl-part-1.html"&gt;SOAP::Lite&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;
&lt;a href="https://metacpan.org/module/SOAP::Data::Builder"&gt;SOAP::Data::Builder&lt;/a&gt; is simply a wrapper around SOAP::Data and SOAP::Serializer for &lt;a href="https://metacpan.org/module/SOAP::Lite"&gt;SOAP::Lite&lt;/a&gt;. I used it because it made my life easier building nested complicated SOAP objects. However for Part 2 I will simply be showing how to use it to do the same code as Part 1. Unfortunately since Part 1 is so Simple this actually makes &lt;a href="https://metacpan.org/module/SOAP::Data::Builder"&gt;SOAP::Data::Builder&lt;/a&gt; more complex than &lt;a href="https://metacpan.org/module/SOAP::Lite"&gt;SOAP::Lite&lt;/a&gt; would be for this. In a future installment I will attempt to show more complex examples, but I will explain them less. Now let's take a look at the code.
&lt;p&gt;
&lt;p&gt;
&lt;script src="https://gist.github.com/1971794.js"&gt; &lt;/script&gt;&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use SOAP::Lite +trace =&gt; [ 'debug' ];
use SOAP::Data::Builder;

my $req = SOAP::Lite-&gt;new(
    readable   =&gt; 1,
    proxy      =&gt; 'http://localhost:8877',
    ns         =&gt; 'http://namesservice.thomas_bayer.com/',
);

my $sb = SOAP::Data::Builder-&gt;new;

$sb-&gt;add_elem(
    name  =&gt; 'name',
    value =&gt; 'Mark',
);

my $res = $req-&gt;getNameInfo( $sb-&gt;to_soap_data );

say '-' x 3;

unless ( defined $res-&gt;fault ) {
    say scalar $res-&gt;valueof('//country');
} else {
    say $res-&gt;fault-&gt;{faultstring};
    say $res-&gt;fault-&gt;{detail}{error};
}&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see this is much the same as the final code in &lt;a href="http://www.xenoterracide.com/2011/10/adventures-with-soap-using-perl-part-1.html"&gt;Part 1&lt;/a&gt;, and if you run it, it does exactly the same thing. The first difference you'll notice is the self explanatory creation of the &lt;a href="https://metacpan.org/module/SOAP::Data::Builder"&gt;SOAP::Data::Builder&lt;/a&gt; object. After that comes the &lt;code&gt;-&gt;add_elem&lt;/code&gt; method call, which will simply create an element with a given element name and a value for that element.
&lt;/p&gt;
&lt;p&gt;
Once you've finished adding elements to your &lt;code&gt;$sb&lt;/code&gt; object, then you can call pass &lt;code&gt;$sb-&gt;to_soap_data&lt;/code&gt; to the method that you're calling on SOAP::Lite, this generates the structure that SOAP::Lite needs to be able to make your request.
&lt;/p&gt;
&lt;p&gt;
The only thing I didn't like about SOAP::Data::Builder is if you don't pass the right parameters to &lt;code&gt;-&gt;add_elem&lt;/code&gt; it will not croak or error in any way that will really tell you what went wrong. &lt;a href="https://github.com/xenoterracide/SOAP-Data-Builder/commit/f16f5d693a366f2d9fd2ecca693e7622a3d24cae"&gt;Simple patches to this can fix it&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;br /&gt;--&lt;br /&gt;
This &lt;span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type"&gt;work&lt;/span&gt; by &lt;a xmlns:cc="http://creativecommons.org/ns#" href="http://www.xenoterracide.com" property="cc:attributionName" rel="cc:attributionURL"&gt;Caleb Cushing&lt;/a&gt; is licensed under a &lt;a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2238114716501996649-8517080194393734898?l=www.xenoterracide.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Hswh_hK7kkjaC6nOz6gM3emHI5w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Hswh_hK7kkjaC6nOz6gM3emHI5w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Hswh_hK7kkjaC6nOz6gM3emHI5w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Hswh_hK7kkjaC6nOz6gM3emHI5w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/xenoterracide/~4/NR132PUfvOs" height="1" width="1"/&gt;</content><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-11T17:10:01.890-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.xenoterracide.com/2012/03/adventures-with-soap-using-perl-part-2.html</feedburner:origLink></entry></feed>

