0
<ul>Maybe you do not know that ... </ul>
$dbh->do()  or die; $sth->execute() or die; #$sth non select statement
So, zero can be true
“ 0.0” “ 0E0” “ +0” “  0”
“ 0 but true”
perl -wE 'say  &quot;0 but true&quot;+5' #5 perl -wE 'say  &quot;0 but true!&quot;+5' Argument &quot;0 but true!&quot; isn...
local
our $l = 5;  {local $l = 4; say $l}; say $l; #4 #5
my $l = 5;  {local $l = 4; say $l}; say $l; #Can't localize lexical variable $l at -e line 2.
my $l = { a => 5 };  { local $l->{a} = 4;  say $l->{a}; };  say $l->{a}; #4 #5
my @l = (2,3,5);  { local $l[2] = 4;  say $l[2]; };  say $l[2]; #4 #5
{ local $h->{RaiseError}; ... }
One line file slurp
$content = do {local(@ARGV, $/) = $f; <ARGV>}
perl -e 'while (<ARGV>){ … }'  f1 f2 f3
@INC
use everywhere 'MooseX::Declare', matching => '^MyApp', use_here => 0;
@INC hooks Subroutine Array Object perldoc -f require
$_
my @ar = qw/h e l l o/; foreach (@ar) { do_something(); say $_; }
Somewhere in outer space... ... Open (my $fh, '<', 'file') while(<$fh>) { ... } ...
my @ar = qw/h e l l o/; foreach (@ar) { do_something(); say $_;  #undef } say “@ar”;  #array of undefs
REGEXP in the wake of hackaton
say “test1” =~ /t1/; say “test2” =~ //;
say “test1” =~ /t1/; # matched say “test2” =~ //; #  not matched
$text =~ m/ $re /;
$text =~ m/ (?:$re) /;
ENV PERL5LIB Is there something else?
PERL5OPT export PERL5OPT='-MData::Dumper' perl -e 'print Dumper([1,2])'
Try::Tiny
Why do we need Try::Tiny Clobbering $@ Localizing $@ silently masks errors $@ might not be a true value Shiny syntax perld...
Fixed in perl 5.14 Clobbering $@ Localizing $@ silently masks errors Remains $@ might not be a true value Shiny syntax
Private accessors/methods
my $name = sub { my $self = shift; ... } $self->$name(); $self->$name('viktor');
use Sub::Name; my $name = subname name => sub { my $self = shift; ... } $self->$name(); $self->$name('viktor');
Word that nobody knows how to pronounce  me too :)
SUITE
SUITE [swi:t]
Thank you! Viktor Turskyi (koorchik) http://koorchik.blogspot.com
Upcoming SlideShare
Loading in...5
×

Maybe you do not know that ...

920

Published on

koorchik's (Viktor Turskyi) presentation from Black Perl 2011.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
920
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Maybe you do not know that ..."

  1. 1. <ul>Maybe you do not know that ... </ul>
  2. 2. $dbh->do() or die; $sth->execute() or die; #$sth non select statement
  3. 3. So, zero can be true
  4. 4. “ 0.0” “ 0E0” “ +0” “ 0”
  5. 5. “ 0 but true”
  6. 6. perl -wE 'say &quot;0 but true&quot;+5' #5 perl -wE 'say &quot;0 but true!&quot;+5' Argument &quot;0 but true!&quot; isn't numeric in addition (+) at -e line 1. #5
  7. 7. local
  8. 8. our $l = 5; {local $l = 4; say $l}; say $l; #4 #5
  9. 9. my $l = 5; {local $l = 4; say $l}; say $l; #Can't localize lexical variable $l at -e line 2.
  10. 10. my $l = { a => 5 }; { local $l->{a} = 4; say $l->{a}; }; say $l->{a}; #4 #5
  11. 11. my @l = (2,3,5); { local $l[2] = 4; say $l[2]; }; say $l[2]; #4 #5
  12. 12. { local $h->{RaiseError}; ... }
  13. 13. One line file slurp
  14. 14. $content = do {local(@ARGV, $/) = $f; <ARGV>}
  15. 15. perl -e 'while (<ARGV>){ … }' f1 f2 f3
  16. 16. @INC
  17. 17. use everywhere 'MooseX::Declare', matching => '^MyApp', use_here => 0;
  18. 18. @INC hooks Subroutine Array Object perldoc -f require
  19. 19. $_
  20. 20. my @ar = qw/h e l l o/; foreach (@ar) { do_something(); say $_; }
  21. 21. Somewhere in outer space... ... Open (my $fh, '<', 'file') while(<$fh>) { ... } ...
  22. 22. my @ar = qw/h e l l o/; foreach (@ar) { do_something(); say $_; #undef } say “@ar”; #array of undefs
  23. 23. REGEXP in the wake of hackaton
  24. 24. say “test1” =~ /t1/; say “test2” =~ //;
  25. 25. say “test1” =~ /t1/; # matched say “test2” =~ //; # not matched
  26. 26. $text =~ m/ $re /;
  27. 27. $text =~ m/ (?:$re) /;
  28. 28. ENV PERL5LIB Is there something else?
  29. 29. PERL5OPT export PERL5OPT='-MData::Dumper' perl -e 'print Dumper([1,2])'
  30. 30. Try::Tiny
  31. 31. Why do we need Try::Tiny Clobbering $@ Localizing $@ silently masks errors $@ might not be a true value Shiny syntax perldoc Try::Tiny
  32. 32. Fixed in perl 5.14 Clobbering $@ Localizing $@ silently masks errors Remains $@ might not be a true value Shiny syntax
  33. 33. Private accessors/methods
  34. 34. my $name = sub { my $self = shift; ... } $self->$name(); $self->$name('viktor');
  35. 35. use Sub::Name; my $name = subname name => sub { my $self = shift; ... } $self->$name(); $self->$name('viktor');
  36. 36. Word that nobody knows how to pronounce me too :)
  37. 37. SUITE
  38. 38. SUITE [swi:t]
  39. 39. Thank you! Viktor Turskyi (koorchik) http://koorchik.blogspot.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×