On Jun 26, 2010, at 3:20 AM, Octavian Rasnita wrote:
Hi,

I have tried the following sample of using inner/augment from the Moose manual:

package Document;

use Moose;

sub as_xml {
 my $self = shift;

 my $xml = "<document>\n";
 $xml .= inner();
 $xml .= "</document>\n";

 return $xml;
}

package Report;

use Moose;
extends 'Document';

augment 'as_xml' => sub {
 my $self = shift;

 my $xml = "<report>\n";
 $xml .= inner();
 $xml .= "</report>\n";

 return $xml;
};

package main;

Report->new->as_xml;

The single result given is:

Use of uninitialized value in concatenation (.) or string at E:\lucru \moose\3\test.pl line 25.

The line 25 is:

 $xml .= inner();

(from the augment modifier)

Am I missing something from the sample script?

Yes, you need to print the return value of the Report->new->as_xml call, which will give you back the XML you are expecting.

The error is not an error, but a warning and it is basically saying that there is nothing being returned by the inner() being called inside Report::as_xml. I recommend changing that to

 $xml .= inner() || '';

And that should clear up the warning.

- Stevan









  • Bug? Octavian Rasnita
    • Re: Bug? Shlomi Fish
    • Re: Bug? Stevan Little

Reply via email to