Thread Code-Erklärung (3 answers)
Opened by Kuerbis at 2014-11-27 18:15

Kuerbis
 2014-11-27 18:15
#178586 #178586
User since
2011-03-20
938 Artikel
BenutzerIn
[default_avatar]
Hallo, kann mir jemand erklären, woher hier das _new in $self = __PACKAGE__->_new(@_); kommt?

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package Unicode::GCString;
require 5.008;

use strict;
use warnings;
use vars qw($VERSION @EXPORT_OK @ISA);

use Exporter;
our @EXPORT_OK = qw();
our %EXPORT_TAGS = ('all' => [@EXPORT_OK]);

our @ISA = qw(Exporter);

use Unicode::LineBreak;

our $VERSION = '2013.10';
 
use overload
    '@{}' => \&as_arrayref,
    '${}' => \&as_scalarref,
    '""' => \&as_string,
    '.' => \&concat,
    #XXX'.=' => \&concat, #FIXME:segfault
    'cmp' => \&cmp,
    '<>' => \&next,
    ;
 
sub new {
    my $class = shift;
 
    my $self;
    if (scalar @_ <= 2) {
        $self = __PACKAGE__->_new(@_);
    } else {
        my $str = shift;
        my $lb = Unicode::LineBreak->new(@_);
        $self = __PACKAGE__->_new($str, $lb);
    }
    bless $self, $class;
}
 
sub as_arrayref {
    my @a = shift->as_array;
    return \@a;
}
 
1;

View full thread Code-Erklärung