Maybe you do not know that ...

  • 861 views
Uploaded on

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

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
861
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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