SlideShare a Scribd company logo
My Perl 
Bag of Tricks 
brian d foy 
The Perl Review 
Baltimore Perl mongers
•Eliminate special cases 
•Remove distractions 
•Know less 
•Let Perl do the work 
•Scale gracefully
% perl -e "print qq(Hello Worldn)" 
! 
% perl -le "print q(Hello World)"
my $string = some_sub(); 
! 
open my $fh, '<', $string; 
! 
while(<$fh>){ 
chomp; 
...; 
}
use 5.014; 
! 
my $new = $old =~ s/.../.../r; 
! 
foo( $old =~ s/.../.../r ); 
! 
print "%s %sn", 
$old, 
$old =~ s/.../.../r 
;
foreach my $file ( @files ) { 
open my($fh), '>', $file or do { 
warn "... $!n"; 
next FILE; 
}; 
... 
}
my $data = do { 
local $/; <DATA> 
}; 
...; 
! 
__END__ 
<?xml version="1.0"?> 
<root> 
... 
</root>
my $data = do { local $/; <DATA> }; 
! 
s|.*(?=<elem>)||; s|(?<=</elem>).*||; 
! 
my $name = 
m|<elem>(.*?)</elem>|; 
! 
__END__ 
<?xml version="1.0"?> 
<root> 
...<elem>Buster</elem> 
</root>
$g = 
q("Mimi","Bean,Buster","Roscoe"); 
! 
my @gatos = split /(?<="),(?=")/, $g;
$g = 
q("Roscoe "","" Cat","Bean, Buster"); 
! 
my @gatos = 
split 
/(?<!"")(?<="),(?=")(?!"")/, $g;
if( ref $r eq 'ARRAY' ) 
! 
if( ref $r eq ref [] ) 
! 
if( ref $r eq ref {} ) 
! 
if( ref $r eq ref sub {} ) 
! 
if( ref $r eq ref qr// )
join "n", @entries, ''; 
! 
join "nt", "t", @entries;
BEGIN { 
use Foo; 
package Foo; 
no warnings qw(redefine); 
sub foo { ... } 
}
# Git::CPAN::Patch 
! 
% git cpan-init http://... 
... hack hack hack ... 
% git commit 
% git cpan-sendpatch
my $file = MPEG::Info->new( ... ); 
! 
print 
join $/, 
map { 
$file->$_() 
} qw(acodec 
acodecraw 
achans 
... 
);
package Modulino { 
run(@ARGV) unless caller; 
! 
sub run { 
my @args = @_; 
...; 
} 
! 
}
if( /p{IsUppercaseRoman}/ ) { 
...} 
! 
# Ⅰ Ⅴ Ⅹ Ⅼ Ⅽ Ⅾ Ⅿ ↁ ↂ ↇ ↈ 
sub IsUppercaseRoman { 
return <<"CODE_NUMBERS"; 
2160 
2164 
2169 
216C 216F 
2181 2182 
2187 2188 
CODE_NUMBERS 
}
printf 
'%1$#b %1$#o %1$d %1$#xn", 
137; 
! 
! 
# 0b10001001 0211 137 0x89
gato( name => 'Buster' ); 
! 
sub gato { 
my %defaults = (...); 
my %config = (%defaults, @_ ); 
...; 
}
BEGIN { 
my $fixed_time = 1234567890; 
no warnings qw(redefine); 
! 
*CORE::GLOBAL::time = 
sub { $fixed_time }; 
! 
sub set_time { 
$fixed_time = $_[0] 
} 
} 
! 
ok( time > $fixed_time );
sub my_grep (&@) { 
my( $sub ) = shift; 
foreach my $arg ( @_ ) { 
local $_ = $arg; 
push @output, $arg 
if $sub->() 
} 
}
my $ucfirst_and_trim = 
composer( 
&trim_front, 
&trim_back, 
&my_ucfirst 
); 
! 
$s = $ucfirst_and_trim->($s);
sub composer { 
my (@sub_refs) = @_; 
sub { 
my $string = shift; 
foreach my $sub_ref (@sub_refs) { 
$string = $sub_ref->($string); 
} 
return $string; 
}; 
}
my @tests = ( 
# ARG EXPECTED LABEL 
[ [1,2,3], 6, 'Sum is 6' ], 
[ [-1,0,9], 8, 'Sum is 8' ], 
... 
); 
! 
foreach my $test ( @tests ) { 
is( 
target_sub( $test->[ARG] ), 
$test->[EXPECTED], 
$test->[LABEL] 
); 
}
package Local::Null::Logger { 
sub new { bless  my $x, $_[0] } 
sub AUTOLOAD { shift; print @_, $/ } 
sub DESTROY { 1 } 
} 
! 
sub _init_logger { 
my $log4perl_loaded = 
eval "require Log::Log4perl; 1"; 
unless( $log4perl_loaded ){ 
return Local::Null::Logger->new; 
} 
...; 
}
$object->foo->bar->baz->quux; 
! 
package Class { 
sub bar { 
return Null->new if $error; 
} 
} 
! 
package Null { 
my $null = bless {}, __PACKAGE__; 
sub new { $null } 
sub AUTOLOAD { return $_[0] } 
sub DESTROY { 1 } 
}

More Related Content

What's hot

Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
Andrew Shitov
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
brian d foy
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
Andrew Shitov
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new features
brian d foy
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
Augusto Pascutti
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
abrummett
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Workhorse Computing
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
heumann
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
Andrew Shitov
 
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)
brian d foy
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
Zend by Rogue Wave Software
 
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)
brian d foy
 
What's New in Perl? v5.10 - v5.16
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
Ricardo Signes
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
Ian Barber
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6
brian d foy
 
7. Lower upper in Laravel
7. Lower upper in Laravel7. Lower upper in Laravel
7. Lower upper in Laravel
Razvan Raducanu, PhD
 

What's hot (20)

Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new features
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Perl5i
Perl5iPerl5i
Perl5i
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)
 
What's New in Perl? v5.10 - v5.16
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6
 
7. Lower upper in Laravel
7. Lower upper in Laravel7. Lower upper in Laravel
7. Lower upper in Laravel
 
Dades i operadors
Dades i operadorsDades i operadors
Dades i operadors
 

Viewers also liked

Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6
brian d foy
 
Tour of the Perl docs
Tour of the Perl docsTour of the Perl docs
Tour of the Perl docs
brian d foy
 
Create and upload your first Perl module to CPAN
Create and upload your first Perl module to CPANCreate and upload your first Perl module to CPAN
Create and upload your first Perl module to CPAN
brian d foy
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transform
brian d foy
 
The Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyThe Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David Smiley
Lucidworks
 
Making My Own CPAN
Making My Own CPANMaking My Own CPAN
Making My Own CPAN
brian d foy
 
Making My Own CPAN
Making My Own CPANMaking My Own CPAN
Making My Own CPAN
brian d foy
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Communitybrian d foy
 
Perl Conferences for Beginners
Perl Conferences for BeginnersPerl Conferences for Beginners
Perl Conferences for Beginners
brian d foy
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
brian d foy
 
Improving the Solr Update Chain
Improving the Solr Update ChainImproving the Solr Update Chain
Improving the Solr Update Chain
Cominvent AS
 

Viewers also liked (12)

I ❤ CPAN
I ❤ CPANI ❤ CPAN
I ❤ CPAN
 
Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6
 
Tour of the Perl docs
Tour of the Perl docsTour of the Perl docs
Tour of the Perl docs
 
Create and upload your first Perl module to CPAN
Create and upload your first Perl module to CPANCreate and upload your first Perl module to CPAN
Create and upload your first Perl module to CPAN
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transform
 
The Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyThe Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David Smiley
 
Making My Own CPAN
Making My Own CPANMaking My Own CPAN
Making My Own CPAN
 
Making My Own CPAN
Making My Own CPANMaking My Own CPAN
Making My Own CPAN
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
 
Perl Conferences for Beginners
Perl Conferences for BeginnersPerl Conferences for Beginners
Perl Conferences for Beginners
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
 
Improving the Solr Update Chain
Improving the Solr Update ChainImproving the Solr Update Chain
Improving the Solr Update Chain
 

Similar to Perl Bag of Tricks - Baltimore Perl mongers

Modern Perl
Modern PerlModern Perl
Modern Perl
Marcos Rebelo
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
garux
 
Programming in perl style
Programming in perl styleProgramming in perl style
Programming in perl style
Bo Hua Yang
 
Ae internals
Ae internalsAe internals
Ae internals
mnikolenko
 
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたR版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
Takeshi Arabiki
 
PHP Tips & Tricks
PHP Tips & TricksPHP Tips & Tricks
PHP Tips & Tricks
Radek Benkel
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
Workhorse Computing
 
spug_2008-08
spug_2008-08spug_2008-08
spug_2008-08
colinmeyer
 
Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)
Michael Schwern
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationAttila Balazs
 
Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)
osfameron
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
 

Similar to Perl Bag of Tricks - Baltimore Perl mongers (20)

Modern Perl
Modern PerlModern Perl
Modern Perl
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
wget.pl
wget.plwget.pl
wget.pl
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
 
Programming in perl style
Programming in perl styleProgramming in perl style
Programming in perl style
 
Tgh.pl
Tgh.plTgh.pl
Tgh.pl
 
Ae internals
Ae internalsAe internals
Ae internals
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたR版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
 
PHP Tips & Tricks
PHP Tips & TricksPHP Tips & Tricks
PHP Tips & Tricks
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
 
spug_2008-08
spug_2008-08spug_2008-08
spug_2008-08
 
Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)Simple Ways To Be A Better Programmer (OSCON 2007)
Simple Ways To Be A Better Programmer (OSCON 2007)
 
perl-pocket
perl-pocketperl-pocket
perl-pocket
 
perl-pocket
perl-pocketperl-pocket
perl-pocket
 
perl-pocket
perl-pocketperl-pocket
perl-pocket
 
perl-pocket
perl-pocketperl-pocket
perl-pocket
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl Presentation
 
Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 

More from brian d foy

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentation
brian d foy
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perl
brian d foy
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
brian d foy
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)
brian d foy
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
brian d foy
 
Backward to DPAN
Backward to DPANBackward to DPAN
Backward to DPAN
brian d foy
 
Perl docs {sux|rulez}
Perl docs {sux|rulez}Perl docs {sux|rulez}
Perl docs {sux|rulez}
brian d foy
 
What's wrong with the perldocs
What's wrong with the perldocsWhat's wrong with the perldocs
What's wrong with the perldocs
brian d foy
 
Frozen Perl 2011 Keynote
Frozen Perl 2011 KeynoteFrozen Perl 2011 Keynote
Frozen Perl 2011 Keynote
brian d foy
 
brian d foy
brian d foybrian d foy
brian d foy
brian d foy
 

More from brian d foy (11)

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentation
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perl
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
 
Backward to DPAN
Backward to DPANBackward to DPAN
Backward to DPAN
 
Perl docs {sux|rulez}
Perl docs {sux|rulez}Perl docs {sux|rulez}
Perl docs {sux|rulez}
 
Why I Love CPAN
Why I Love CPANWhy I Love CPAN
Why I Love CPAN
 
What's wrong with the perldocs
What's wrong with the perldocsWhat's wrong with the perldocs
What's wrong with the perldocs
 
Frozen Perl 2011 Keynote
Frozen Perl 2011 KeynoteFrozen Perl 2011 Keynote
Frozen Perl 2011 Keynote
 
brian d foy
brian d foybrian d foy
brian d foy
 

Recently uploaded

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 

Recently uploaded (20)

From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 

Perl Bag of Tricks - Baltimore Perl mongers

  • 1. My Perl Bag of Tricks brian d foy The Perl Review Baltimore Perl mongers
  • 2. •Eliminate special cases •Remove distractions •Know less •Let Perl do the work •Scale gracefully
  • 3. % perl -e "print qq(Hello Worldn)" ! % perl -le "print q(Hello World)"
  • 4. my $string = some_sub(); ! open my $fh, '<', $string; ! while(<$fh>){ chomp; ...; }
  • 5. use 5.014; ! my $new = $old =~ s/.../.../r; ! foo( $old =~ s/.../.../r ); ! print "%s %sn", $old, $old =~ s/.../.../r ;
  • 6. foreach my $file ( @files ) { open my($fh), '>', $file or do { warn "... $!n"; next FILE; }; ... }
  • 7. my $data = do { local $/; <DATA> }; ...; ! __END__ <?xml version="1.0"?> <root> ... </root>
  • 8. my $data = do { local $/; <DATA> }; ! s|.*(?=<elem>)||; s|(?<=</elem>).*||; ! my $name = m|<elem>(.*?)</elem>|; ! __END__ <?xml version="1.0"?> <root> ...<elem>Buster</elem> </root>
  • 9. $g = q("Mimi","Bean,Buster","Roscoe"); ! my @gatos = split /(?<="),(?=")/, $g;
  • 10. $g = q("Roscoe "","" Cat","Bean, Buster"); ! my @gatos = split /(?<!"")(?<="),(?=")(?!"")/, $g;
  • 11. if( ref $r eq 'ARRAY' ) ! if( ref $r eq ref [] ) ! if( ref $r eq ref {} ) ! if( ref $r eq ref sub {} ) ! if( ref $r eq ref qr// )
  • 12. join "n", @entries, ''; ! join "nt", "t", @entries;
  • 13. BEGIN { use Foo; package Foo; no warnings qw(redefine); sub foo { ... } }
  • 14. # Git::CPAN::Patch ! % git cpan-init http://... ... hack hack hack ... % git commit % git cpan-sendpatch
  • 15. my $file = MPEG::Info->new( ... ); ! print join $/, map { $file->$_() } qw(acodec acodecraw achans ... );
  • 16. package Modulino { run(@ARGV) unless caller; ! sub run { my @args = @_; ...; } ! }
  • 17. if( /p{IsUppercaseRoman}/ ) { ...} ! # Ⅰ Ⅴ Ⅹ Ⅼ Ⅽ Ⅾ Ⅿ ↁ ↂ ↇ ↈ sub IsUppercaseRoman { return <<"CODE_NUMBERS"; 2160 2164 2169 216C 216F 2181 2182 2187 2188 CODE_NUMBERS }
  • 18. printf '%1$#b %1$#o %1$d %1$#xn", 137; ! ! # 0b10001001 0211 137 0x89
  • 19. gato( name => 'Buster' ); ! sub gato { my %defaults = (...); my %config = (%defaults, @_ ); ...; }
  • 20. BEGIN { my $fixed_time = 1234567890; no warnings qw(redefine); ! *CORE::GLOBAL::time = sub { $fixed_time }; ! sub set_time { $fixed_time = $_[0] } } ! ok( time > $fixed_time );
  • 21. sub my_grep (&@) { my( $sub ) = shift; foreach my $arg ( @_ ) { local $_ = $arg; push @output, $arg if $sub->() } }
  • 22. my $ucfirst_and_trim = composer( &trim_front, &trim_back, &my_ucfirst ); ! $s = $ucfirst_and_trim->($s);
  • 23. sub composer { my (@sub_refs) = @_; sub { my $string = shift; foreach my $sub_ref (@sub_refs) { $string = $sub_ref->($string); } return $string; }; }
  • 24. my @tests = ( # ARG EXPECTED LABEL [ [1,2,3], 6, 'Sum is 6' ], [ [-1,0,9], 8, 'Sum is 8' ], ... ); ! foreach my $test ( @tests ) { is( target_sub( $test->[ARG] ), $test->[EXPECTED], $test->[LABEL] ); }
  • 25. package Local::Null::Logger { sub new { bless my $x, $_[0] } sub AUTOLOAD { shift; print @_, $/ } sub DESTROY { 1 } } ! sub _init_logger { my $log4perl_loaded = eval "require Log::Log4perl; 1"; unless( $log4perl_loaded ){ return Local::Null::Logger->new; } ...; }
  • 26. $object->foo->bar->baz->quux; ! package Class { sub bar { return Null->new if $error; } } ! package Null { my $null = bless {}, __PACKAGE__; sub new { $null } sub AUTOLOAD { return $_[0] } sub DESTROY { 1 } }