The document discusses new features and changes in Perl 5.10. Some key points include:
- Perl 5.10 introduces many new features and changes that are not backwards compatible with Perl 5.8.x.
- Notable new features include lexically scoped pragmas, pluggable regular expression engines, smarter pattern matching, and state variables.
- The document provides examples of new operators and functions like smart matching (~~), given/when, and say that output a newline.
7. 5.10 is Way Cool
- no significant new features in Perl since 2002
perl51000delta
8. 5.10 is Way Cool
- no significant new features in Perl since 2002
- remember how bad you wanted to see Star
Wars: Episode 1?
perl51000delta
9. 5.10 is Way Cool
- no significant new features in Perl since 2002
- remember how bad you wanted to see Star
Wars: Episode 1?
- that’s how excited you should be for 5.10
perl51000delta
10. 5.10 is Way Cool
- no significant new features in Perl since 2002
- remember how bad you wanted to see Star
Wars: Episode 1?
- that’s how excited you should be for 5.10
- but it won’t suck (no POD race scene)
perl51000delta
17. Yes, You Care
- Not everything in 5.10 is esoteric.
perl51000delta
18. Yes, You Care
- Not everything in 5.10 is esoteric.
- Not everything in 5.10 is for gurus.
perl51000delta
19. Yes, You Care
- Not everything in 5.10 is esoteric.
- Not everything in 5.10 is for gurus.
- Not everything in 5.10 is for C programmers.
perl51000delta
20. Yes, You Care
- Not everything in 5.10 is esoteric.
- Not everything in 5.10 is for gurus.
- Not everything in 5.10 is for C programmers.
- Not everything in 5.10 is super advanced.
perl51000delta
23. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
feature
24. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
- they’re not enabled by default
feature
25. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
- they’re not enabled by default
- use feature ‘mtfnpy’;
feature
26. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
- they’re not enabled by default
- use feature ‘mtfnpy’;
- use 5.010;
feature
27. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
- they’re not enabled by default
- use feature ‘mtfnpy’;
- use 5.010;
- read the perldoc
feature
28. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
- they’re not enabled by default
- use feature ‘mtfnpy’;
- use 5.010;
- read the perldoc I’m a perldoc
ref!
feature
29. First: A Warning
- 5.10 is backwards compatible
- but adds new keywords and operators
- they’re not enabled by default
- use feature ‘mtfnpy’;
- use 5.010;
- read the perldoc
feature
68. Smart Matching
- a new kind of comparison operator
- its behavior depends on its inputs
perlsyn
69. Smart Matching
- a new kind of comparison operator
- its behavior depends on its inputs
- “if these two things match...”
perlsyn
70. Smart Matching
- a new kind of comparison operator
- its behavior depends on its inputs
- “if these two things match...”
- hard to tell, easy to show...
perlsyn
112. Better Error Message(s)
$str = “Greetings, $name. Your last
login was $last. It is now $time.”;
Use of uninitialized value in
concatenation (.) or string at
hello.plx line 9.
perldiag
113. Better Error Message(s)
$str = “Greetings, $name. Your last
login was $last. It is now $time.”;
Use of uninitialized value $time in
concatenation (.) or string at
hello.plx line 9.
perldiag
118. Inside-Out Objects
- traditional objects are a hashref
- look up attrs in the obj itself by attr name
- inside-out objects are content-free refs
Hash::Util::FieldHash
119. Inside-Out Objects
- traditional objects are a hashref
- look up attrs in the obj itself by attr name
- inside-out objects are content-free refs
- look up attrs in an external hash by obj id
Hash::Util::FieldHash
120. Inside-Out Objects
- traditional objects are a hashref
- look up attrs in the obj itself by attr name
- inside-out objects are content-free refs
- look up attrs in an external hash by obj id
- there are complications for inside-out objects
Hash::Util::FieldHash
121. Inside-Out Objects
sub size {
my $self = shift;
if (@_) {
return $self->{size} = shift;
} else {
return $self->{size};
}
}
Hash::Util::FieldHash
122. Inside-Out Objects
my %size;
sub size {
my $self = shift;
if (@_) {
return $size{ $self } = shift;
} else {
return $size{ $self };
}
}
Hash::Util::FieldHash
123. Inside-Out Objects
my %size;
sub size {
my $self = shift;
my $id = refaddr $self;
if (@_) {
return $size{ $id } = shift;
} else {
return $size{ $id };
}
}
Hash::Util::FieldHash
124. Inside-Out Objects
my %size;
sub size {
my $self = shift;
my $id = refaddr $self;
if (@_) {
return $size{ $id } = shift;
} else {
return $size{ $id };
}
}
sub DESTROY {
my $id = refaddr $_[0];
delete $size{ $id };
}
Hash::Util::FieldHash
125. Inside-Out Objects
my %size; sub CLONE {
sub size { my $class = shift;
my $self = shift;
my $id = refaddr $self; my @properties = map { values %$_ }
values %PROP_DATA_FOR;
if (@_) {
return $size{ $id } = shift; for my $old_id ( keys %OBJ ) {
} else {
return $size{ $id }; my $object = $OBJ{ $old_id };
} my $new_id = refaddr $object;
}
for my $prop ( @properties ) {
sub DESTROY { next unless exists $prop->{ $old };
my $id = refaddr $_[0]; $prop->{ $new } = $prop->{ $old };
delete $size{ $id }; delete $prop->{ $old };
} }
weaken ( $OBJ{ $new } = $object );
delete $OBJ{ $old };
}
}
Hash::Util::FieldHash
126. Inside-Out Objects
my %OBJECT_REGISTRY; sub CLONE {
my %size; my $class = shift;
sub size {
my $self = shift; my @properties = map { values %$_ }
my $id = refaddr $self; values %PROP_DATA_FOR;
$self->register_object; for my $old_id ( keys %OBJECT_REGISTRY )
{
if (@_) {
return $size{ $self } = shift; my $object =
} else { $OBJECT_REGISTRY{ $old_id };
return $size{ $self }; my $new_id = refaddr $object;
}
} for my $prop ( @properties ) {
next unless exists $prop-
sub DESTROY { >{ $old_id };
my $id = refaddr $_[0]; $prop->{ $new_id } = $prop-
delete $size{ $id }; >{ $old_id };
delete $OBJECT_REGISTRY{ $id }; delete $prop->{ $old_id };
} }
sub register_object { weaken ( $OBJECT_REGISTRY{ $new_id } =
my ($self) = @_; $object );
my $id = refaddr $self; delete $OBJECT_REGISTRY{ $old_id };
$OBJECT_REGISTRY{ $id } = $self; }
} }
Hash::Util::FieldHash
137. Lexical Topic
for (@lines) {
chomp;
next if /^#/;
next unless length;
s/a/b/;
sanity_check;
say;
}
perlvar
138. Lexical Topic
for my $line (@lines) {
chomp $line;
next if $line ~~ /^#/;
next unless length $line;
$line =~ s/a/b/;
sanity_check($line);
say $line;
}
perlvar
139. Lexical Topic
for my $_ (@lines) {
chomp;
next if /^#/;
next unless length;
s/a/b/;
sanity_check;
say;
}
perlvar