This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
compatibility tweak for Class::Struct
[perl5.git] / lib / Class / Struct.pm
index d8327bc..3e08e80 100644 (file)
@@ -101,6 +101,7 @@ sub struct {
 
     $out = "{\n  package $class;\n  use Carp;\n  sub new {\n";
     $out .= "    my (\$class, \%init) = \@_;\n";
+    $out .= "    \$class = __PACKAGE__ unless \@_;\n";
 
     my $cnt = 0;
     my $idx = 0;