SlideShare a Scribd company logo
1 of 23
The WTFish side  of using Perl Lech Baczyński http://perl.baczynski.com
Thanks, Hurra I would like to thank Hurra Communications, the company that sponsored my trip here, probably the most Perl-ish company in Poland www.hurra.com
What do I mean by WTF Strange unexpected results of Perl code: ,[object Object]
Perl's strange behaviour (both seem to be the same after a while :-) ) Examples: foreach variable localization, “zero but true”, dangers of omitting brackets, lazy  print ... Some are for beginners (not-beginners – have patience!), some may puzzle intermediate programmers.
Lazy print Let's say you would like to see progress of a long computing... foreach my $element (@array) { # ..... long time operations ... $i++; if ( $i % 100 == 0) {  print ".";  }; Will it print dot every 100th iteration?  No. It will print all of them at once at the end.
Lazy print - continued $|++ WTF is $|++ ? It is incrementing one of Perl's strange variables (magic punctuation variables). $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel.  Using $|++ is not perl best practice. Solution:  use English; # '-no_match_vars'; then use the $OUTPUT_AUTOFLUSH  variable
Who needs brackets Omitting brackets – both convenient and dangerous $a="Hello"; $b="world"; print $a . " " . $b . ""; print "Found ". scalar @arr ." elements";
Who needs brackets - continued $a = 'Hello'; print ( length ( $a ) ); print length $a; output: 5 - ok print length $a . " letters" ; output: 14 – WTF?? Length was calculated of concatenated strings $a and "letters", thus length returned 14.  So beware - sometimes you may ignore brackets, sometimes you may not.
Regexps: {n,m} Let's say you want to match three to five small letters : /[a-z]{3,5}/ And now any number not less than three /[a-z]{3,}/ And now, analogically, any number not more than five /[a-z]{,5}/   # WRONG It works only one way - {n,}, not {,n} - the explanation is easy: you can easily write 0, but it not so easy to write infinity
Regexps: Minus (-) sign in character classes [ ] Beware of matching "-" in regexps. If you want to match letters a,b,c and minus sign: Good:  [-abc] Good:  [abc-] Bad: [a-bc] Good: [abc]
Regexps: delimiters Only if you use // then m is optional.  Some need to be closed other way than opened. /abc/  - ok |abc|  - wrong m|abc|  - will work m/abc/  - will work, m is optional m#abc#  - will work, not a comment m(abc) m{abc} m[abc]  - ok Perl Bast Practices: Don't use any delimiters other than // or m{}
Foreach  var localization  my @array = (1,2,3); my $var = 'foo'; foreach $var (@array) {  # note - no "my $var"  print $var . ""; } print 'Value after the loop: ' . $var . ""; Value of $var after loop is “foo”. It is the same as before loop! WTF?
Foreach  var localization - continued The same example but with $_  $_ = 'foo'; print; foreach (@array) { print; } print; And again, the $_ is the same as before loop! This behavior can be observed in "foreach" loops, but not in "while" loops. So be careful.
So, you would like to create two dimensional array? @array = ( (1,2,3), (4,5,6), (7,8,9)); Wrong. It makes @aray = (1,2,3,4,5,6,7,8,9);.  This is caled array flattening.  @array = ( [1,2,3], [4,5,6], [7,8,9]); You do not get exactly array of arrays - you get the array of references to array.
Autodefining var my $var;   # $var is not defined if (defined $var) { warn "yes"; } else {  warn "no"; } # warns: "no" if (defined $var->{'foo'}) {  warn "yes"; } else { warn "no"; } # well, it is not defined. But  "if (defined $var->{'foo'})" made our $var defined! if (defined $var) {  warn "yes"; } else { warn "no"; }  # warns: "yes"! print ref $var;   # HASH! Analogically, if ($var->[0]) makes an empty arrayref.
Fun with counting months, years and weekdays ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); Month day: from  1  to  31 Month:  0  to  11.  WTF? Explanation: This makes it easy to get a month name from a list: my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );  print "$abbr[$mon] $mday";
Fun with counting months, years and weekdays $year  is the number of years since 1900, not just the last two digits of the year. That is,  $year  is 123 in year 2023. We have seen using last two digits for year, and Y2K problems it made. We have seen counting time from 1970. We have seen counting time from begining of A.D. (like: 2009). So why 1900? It is strange, but it is the same in C and Java. Perl inherited it from C libs. It neither have the possiblility to store year in two digits, nor the possiblility not force  programmers to count year in special way. $year += 1900;
Fun with counting months, years and weekdays $wday is the day of the week, with 0 indicating Sunday and 3 indicating Wednesday. Monday is 1st, Saturday is 5th, Sunday is zeroth. Beware that Sunday is not 7th, nor 1st, as most people would thought. This solution is good for both groups of people - those that think that Monday is first day of weeks (as it is 1st) and those that Sunday is at the beginning of the week (as it is zeroth) ;-) Just be aware of those little traps in localtime.
Three ways of calling subroutine sub my_subroutine {... ,[object Object]
my_subroutine();  No need to declare earlier
&my_subroutine;  No need to declare earlier, too, but it passes the content of @_ to called subroutine! If you call subroutine with the "&" at beginning, you get an implicit argument list passed that you probably did not intend.
last  in function Imagine you have a loop and call a function (sub) in it – your, or from some module. And someone by mistake left there  last . It terminates your loop. for … { something…; function(); something… that would not be executed… }; For some people it is a WTF, for some it is very logical way, that it should work like.
The truth is out there What is false? ,[object Object]

More Related Content

Similar to WTFin Perl

Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1Dave Cross
 
Embed--Basic PERL XS
Embed--Basic PERL XSEmbed--Basic PERL XS
Embed--Basic PERL XSbyterock
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fuclimatewarrior
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Languagezone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoobirbal
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de JavascriptBernard Loire
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaMarko Gargenta
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...Viktor Turskyi
 
Php Loop
Php LoopPhp Loop
Php Looplotlot
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 

Similar to WTFin Perl (20)

Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Embed--Basic PERL XS
Embed--Basic PERL XSEmbed--Basic PERL XS
Embed--Basic PERL XS
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
Simple perl scripts
Simple perl scriptsSimple perl scripts
Simple perl scripts
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, Marakana
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...
 
Php Loop
Php LoopPhp Loop
Php Loop
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

WTFin Perl

  • 1. The WTFish side of using Perl Lech Baczyński http://perl.baczynski.com
  • 2. Thanks, Hurra I would like to thank Hurra Communications, the company that sponsored my trip here, probably the most Perl-ish company in Poland www.hurra.com
  • 3.
  • 4. Perl's strange behaviour (both seem to be the same after a while :-) ) Examples: foreach variable localization, “zero but true”, dangers of omitting brackets, lazy print ... Some are for beginners (not-beginners – have patience!), some may puzzle intermediate programmers.
  • 5. Lazy print Let's say you would like to see progress of a long computing... foreach my $element (@array) { # ..... long time operations ... $i++; if ( $i % 100 == 0) { print "."; }; Will it print dot every 100th iteration? No. It will print all of them at once at the end.
  • 6. Lazy print - continued $|++ WTF is $|++ ? It is incrementing one of Perl's strange variables (magic punctuation variables). $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Using $|++ is not perl best practice. Solution: use English; # '-no_match_vars'; then use the $OUTPUT_AUTOFLUSH variable
  • 7. Who needs brackets Omitting brackets – both convenient and dangerous $a="Hello"; $b="world"; print $a . " " . $b . ""; print "Found ". scalar @arr ." elements";
  • 8. Who needs brackets - continued $a = 'Hello'; print ( length ( $a ) ); print length $a; output: 5 - ok print length $a . " letters" ; output: 14 – WTF?? Length was calculated of concatenated strings $a and "letters", thus length returned 14. So beware - sometimes you may ignore brackets, sometimes you may not.
  • 9. Regexps: {n,m} Let's say you want to match three to five small letters : /[a-z]{3,5}/ And now any number not less than three /[a-z]{3,}/ And now, analogically, any number not more than five /[a-z]{,5}/ # WRONG It works only one way - {n,}, not {,n} - the explanation is easy: you can easily write 0, but it not so easy to write infinity
  • 10. Regexps: Minus (-) sign in character classes [ ] Beware of matching "-" in regexps. If you want to match letters a,b,c and minus sign: Good: [-abc] Good: [abc-] Bad: [a-bc] Good: [abc]
  • 11. Regexps: delimiters Only if you use // then m is optional. Some need to be closed other way than opened. /abc/ - ok |abc| - wrong m|abc| - will work m/abc/ - will work, m is optional m#abc# - will work, not a comment m(abc) m{abc} m[abc] - ok Perl Bast Practices: Don't use any delimiters other than // or m{}
  • 12. Foreach var localization my @array = (1,2,3); my $var = 'foo'; foreach $var (@array) { # note - no "my $var" print $var . ""; } print 'Value after the loop: ' . $var . ""; Value of $var after loop is “foo”. It is the same as before loop! WTF?
  • 13. Foreach var localization - continued The same example but with $_ $_ = 'foo'; print; foreach (@array) { print; } print; And again, the $_ is the same as before loop! This behavior can be observed in "foreach" loops, but not in "while" loops. So be careful.
  • 14. So, you would like to create two dimensional array? @array = ( (1,2,3), (4,5,6), (7,8,9)); Wrong. It makes @aray = (1,2,3,4,5,6,7,8,9);. This is caled array flattening. @array = ( [1,2,3], [4,5,6], [7,8,9]); You do not get exactly array of arrays - you get the array of references to array.
  • 15. Autodefining var my $var; # $var is not defined if (defined $var) { warn "yes"; } else { warn "no"; } # warns: "no" if (defined $var->{'foo'}) { warn "yes"; } else { warn "no"; } # well, it is not defined. But "if (defined $var->{'foo'})" made our $var defined! if (defined $var) { warn "yes"; } else { warn "no"; } # warns: "yes"! print ref $var; # HASH! Analogically, if ($var->[0]) makes an empty arrayref.
  • 16. Fun with counting months, years and weekdays ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); Month day: from 1 to 31 Month: 0 to 11. WTF? Explanation: This makes it easy to get a month name from a list: my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); print "$abbr[$mon] $mday";
  • 17. Fun with counting months, years and weekdays $year is the number of years since 1900, not just the last two digits of the year. That is, $year is 123 in year 2023. We have seen using last two digits for year, and Y2K problems it made. We have seen counting time from 1970. We have seen counting time from begining of A.D. (like: 2009). So why 1900? It is strange, but it is the same in C and Java. Perl inherited it from C libs. It neither have the possiblility to store year in two digits, nor the possiblility not force programmers to count year in special way. $year += 1900;
  • 18. Fun with counting months, years and weekdays $wday is the day of the week, with 0 indicating Sunday and 3 indicating Wednesday. Monday is 1st, Saturday is 5th, Sunday is zeroth. Beware that Sunday is not 7th, nor 1st, as most people would thought. This solution is good for both groups of people - those that think that Monday is first day of weeks (as it is 1st) and those that Sunday is at the beginning of the week (as it is zeroth) ;-) Just be aware of those little traps in localtime.
  • 19.
  • 20. my_subroutine(); No need to declare earlier
  • 21. &my_subroutine; No need to declare earlier, too, but it passes the content of @_ to called subroutine! If you call subroutine with the "&" at beginning, you get an implicit argument list passed that you probably did not intend.
  • 22. last in function Imagine you have a loop and call a function (sub) in it – your, or from some module. And someone by mistake left there last . It terminates your loop. for … { something…; function(); something… that would not be executed… }; For some people it is a WTF, for some it is very logical way, that it should work like.
  • 23.
  • 26. undef
  • 27. () empty list what about "0.0"? And "0E0"? "0.0", "0E0", "0 but true","false","foo" are all true. 0.0 is false (number, not string)
  • 28. The truth is out there “0 but true” - self documenting WTF :) It is true, but when treated as a number it is zero. print "0 but true" ? "true" : "false"; print "0 but true" + 0 ? "true" : "false"; First is true, second is false. You can add it to number: print "0 but true" + 7; As most other strings: print "foo" + 7; Beware of strings starting with inf... nad nan...
  • 29. Comparing apples to oranges if ("apple" == "orange") { .... True! Beware of "==" and "eq" difference. "==" is for numbers, "eq" for strings. perl 5.10 and later: $scalar ~~ $scalar; If both look like numbers, do "==", otherwise do "eq"
  • 30. That's all folks! Thank you.