needs that lead to the camel                          Per l                              1987                            1...
needs that lead to the camel LD12                         a genda                         . scenario                      ...
needs that lead to the camel LD12                         scenariold12 - imolug   pvb265
a genda                                                                       needs that lead to the camel LD12  . scenari...
a genda                                                                                  needs that lead to the camel LD12...
a genda                                                                                  needs that lead to the camel LD12...
a genda                                                                                   needs that lead to the camel LD1...
a genda                                                                                   needs that lead to the camel LD1...
a genda                                                                                    needs that lead to the camel LD...
a genda                                                                                    needs that lead to the camel LD...
a genda                                                                                  needs that lead to the camel LD12...
a genda                                                                                                              needs...
a genda                                                                                  needs that lead to the camel LD12...
needs that lead to the camel LD12                         canonical wayld12 - imolug   pvb265
a genda                                   needs that lead to the camel LD12  . scenario  . canonical way  . faster way  .....
a genda                                                                           needs that lead to the camel LD12  . sce...
a genda                                                                         needs that lead to the camel LD12  . scena...
a genda                                                                                 needs that lead to the camel LD12 ...
a genda                                                                                     needs that lead to the camel L...
a genda                                                                                     needs that lead to the camel L...
a genda                                                                                     needs that lead to the camel L...
a genda                                                                                     needs that lead to the camel L...
a genda                                                           needs that lead to the camel LD12  . scenario  . canonic...
a genda                                                                                          needs that lead to the ca...
a genda                                                                                          needs that lead to the ca...
needs that lead to the camel LD12                         faster wayld12 - imolug   pvb265
a genda                                               needs that lead to the camel LD12  . scenario  . canonical way  . fa...
a genda                                                                                needs that lead to the camel LD12  ...
a genda                                                                                needs that lead to the camel LD12  ...
a genda                                                                                needs that lead to the camel LD12  ...
a genda                                                                                needs that lead to the camel LD12  ...
a genda                                                              needs that lead to the camel LD12  . scenario  . cano...
a genda                                                              needs that lead to the camel LD12  . scenario  . cano...
a genda                                                                                                      needs that le...
a genda                                                                                                           needs th...
a genda                                                                                                          needs tha...
a genda                                                                                                           needs th...
a genda                                                                                                          needs tha...
a genda                                                                                                          needs tha...
a genda                                                                                                          needs tha...
a genda                                                                                                           needs th...
a genda                                                                                                           needs th...
a genda                                                                                                        needs that ...
needs that lead to the camel LD12                         faster way                           Perl genesisld12 - imolug  ...
a genda                                                                                   needs that lead to the camel LD1...
a genda                                                                                                     needs that lea...
a genda                                                                                                     needs that lea...
a genda                                                                                                     needs that lea...
a genda                                                                                                     needs that lea...
needs that lead to the camel LD12                           faster way                         compiler vs interpreterld12...
a genda                                                            needs that lead to the camel LD12  . scenario  . canoni...
a genda                                                          needs that lead to the camel LD12  . scenario  . canonica...
a genda                                                              needs that lead to the camel LD12  . scenario  . cano...
a genda                                                                  needs that lead to the camel LD12  . scenario  . ...
a genda                                                                  needs that lead to the camel LD12  . scenario  . ...
a genda                                                                  needs that lead to the camel LD12  . scenario  . ...
a genda                                                                     needs that lead to the camel LD12  . scenario ...
a genda                                                                     needs that lead to the camel LD12  . scenario ...
a genda                                                                     needs that lead to the camel LD12  . scenario ...
a genda                                                            needs that lead to the camel LD12  . scenario  . canoni...
a genda                                                            needs that lead to the camel LD12  . scenario  . canoni...
needs that lead to the camel LD12                          faster way                         basics by examplesld12 - imo...
a genda                                                             needs that lead to the camel LD12  . scenario  . canon...
a genda                                                          needs that lead to the camel LD12  . scenario  . canonica...
a genda                                                            needs that lead to the camel LD12  . scenario  . canoni...
a genda                                                                  needs that lead to the camel LD12  . scenario  . ...
a genda                                                                     needs that lead to the camel LD12  . scenario ...
a genda                                                                       needs that lead to the camel LD12  . scenari...
a genda                                                                             needs that lead to the camel LD12  . s...
a genda                                                                         needs that lead to the camel LD12  . scena...
a genda                                                                                 needs that lead to the camel LD12 ...
a genda                                                                           needs that lead to the camel LD12  . sce...
needs that lead to the camel LD12                         faster way                           not to dold12 - imolug   pv...
a genda                                                   needs that lead to the camel LD12  . scenario  . canonical way  ...
a genda                                                                             needs that lead to the camel LD12  . s...
a genda                                                                                needs that lead to the camel LD12  ...
a genda                                                                                                        needs that ...
a genda                                                                                                      needs that le...
needs that lead to the camel LD12                         thanks Lar r y                         thanks Angel             ...
a genda                                                                                . scenario                         ...
pearls of Perl
pearls of Perl
pearls of Perl
Upcoming SlideShare
Loading in …5
×

pearls of Perl

485
-1

Published on

using perl in real life of a sysadm, not a fan story, but a concrete example to solve every day problemd

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

No notes for slide

pearls of Perl

  1. 1. needs that lead to the camel Per l 1987 18 Decemberld12 - imolug pvb265
  2. 2. needs that lead to the camel LD12 a genda . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larryld12 - imolug pvb265
  3. 3. needs that lead to the camel LD12 scenariold12 - imolug pvb265
  4. 4. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry ● our e-commerce site is slow ● we are loosing money due to slow performance ● the users experience says that the site is unusable ld12 - imolug pvb265
  5. 5. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● resolve the issue ● do it soon ld12 - imolug pvb265
  6. 6. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● resolve the issue ● do it soon db-server ld12 - imolug pvb265
  7. 7. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● resolve the issue ● do it soon app-server db-server ld12 - imolug pvb265
  8. 8. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● resolve the issue ● do it soon web-server app-server db-server ld12 - imolug pvb265
  9. 9. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● resolve the issue ● do it soon web-cluster app-cluster db-cluster ld12 - imolug pvb265
  10. 10. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● resolve the issue ● do it soon ● complexity and high reliability web-cluster app-cluster db-cluster ld12 - imolug pvb265
  11. 11. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● logs are our best friends ● logs must exists ● logs must be readable ● logs may be very large ld12 - imolug pvb265
  12. 12. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● logs are our best friends MacBook-Pro-di-valerio:data valeriobalbi$ ls -l total 208392 -rw-r--r-- 1 valeriobalbi staff 106676224 24 Set 16:57 www.imolugcommerce.com-access.log MacBook-Pro-di-valerio:data valeriobalbi$ head 10 www.imolugcommerce.com-access.log head: 10: No such file or directory ==> www.imolugcommerce.com-access.log <== 109.93.188.182,-,-,[09/Apr/2012:23:59:05,+0200],0,200,8895,109.93.188.182,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TSTB 109.93.188.182,-,-,[09/Apr/2012:23:59:05,+0200],0,200,5737,109.93.188.182,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TSTB 109.112.65.154,-,-,[09/Apr/2012:23:59:05,+0200],0,200,19398,109.112.65.154,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TST 109.93.188.182,-,-,[09/Apr/2012:23:59:05,+0200],0,200,13405,109.93.188.182,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TST 109.121.26.105,-,-,[09/Apr/2012:23:59:04,+0200],0,200,16210,109.121.26.105,www.imolugcommerce.com,(mod_was_ap22_http.c/-2/handler),wcn 109.93.188.182,-,-,[09/Apr/2012:23:59:05,+0200],0,200,893,109.93.188.182,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TSTB2 79.103.238.28,-,-,[09/Apr/2012:23:59:05,+0200],0,404,333,79.103.238.28,www.imolugcommerce.com,(core.c/404/handler),-,"GET,/wcsstore/TSTB2 109.112.65.154,-,-,[09/Apr/2012:23:59:05,+0200],0,200,4612,109.112.65.154,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TSTB 109.112.65.154,-,-,[09/Apr/2012:23:59:05,+0200],0,200,1333,109.112.65.154,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TSTB 109.112.65.154,-,-,[09/Apr/2012:23:59:05,+0200],0,200,1062,109.112.65.154,www.imolugcommerce.com,(core.c/0/handler),-,"GET,/wcsstore/TSTB ld12 - imolug pvb265
  13. 13. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do ● our e-commerce site is slow . thanks Larry ● we are loosing money due to slow performance ● the users experience says that the site is unusable ● logs are our best friends ● response/minute ● return code http/minute ● top ten sloow response ld12 - imolug pvb265
  14. 14. needs that lead to the camel LD12 canonical wayld12 - imolug pvb265
  15. 15. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry Bash Sed Awk ld12 - imolug pvb265
  16. 16. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Bash .. basics by examples .. not to do . thanks Larry Sed Awk Brian Fox GNU Project 1989 command processor script wildcard piping variables Bourne-again shell command($@) = $? stdOUT stdIN → command → command1 && command2 stdERR command1 || command2 command [ | command2 ... ] while list; do list; done $(command) `command` until list; do list; done $((expression)) ld12 - imolug pvb265
  17. 17. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Bash Sed Awk .. basics by examples .. not to do . thanks Larry stream editor Unix utility parser text transformations line by line 1974 Lee E. McMahon sed -e s/old/new/g inputFileName > outputFileName cat inputFileName | sed -e s/old/new/g cat inputFileName | sed s/pattern//g cat inputFileName | sed /pattern/d s/^$/VOIDLINE/g s/^[01]*a[bc]*//g ld12 - imolug pvb265
  18. 18. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Bash Sed Awk .. basics by examples .. not to do . thanks Larry Bell Labs 1977 operations on fields Alfred Aho, Peter Weinberger, Brian Kernighan all OS associative arrays regular expressions line_oriented condition { action } cat inputFileName | awk { print $1 $2 } awk { print $1 $2 } inputFileName > outputFileName Inline awk -F: { print $1 $2 } inputFileName script awk -f myscript.awk inputFileName awk if ( NR > 10 ) { print $1 $2 } BEGIN { FS=":" } { print $1 } END { print “hello world!” } ld12 - imolug pvb265
  19. 19. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do #!/bin/bash . thanks Larry MAXMIN=1440 LOGFILE=$1 declare -ax vect echo "Inizializzazione $(date)" for (( i=0 ; $i<$MAXMIN ; i++ )) ; do vect[$i]=0 ; done echo "Analisi File $(date)" IFS="," while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 do minute=$(echo $a4|awk -F: { print $3} |sed s/^0*//g) awk sed hour=$(echo $a4|awk -F: { print $2} |sed s/^0*//g) sed if [ "$minute." == "." ]; then minute=0; fi if [ "$hour." == "." ]; then hour=0; fi tmp_m=$(($hour*60)) minutes=$(($tmp_m+$minute)) vect[$minutes]=$((${vect[$minutes]}+1)) done < $LOGFILE echo "risultati $(date)" for ( i=0 ; $i<$MAXMIN ; i++ ) ; do echo -n "$i " echo ${vect[$i]} done echo "fine $(date)" ld12 - imolug pvb265
  20. 20. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do #!/bin/bash . thanks Larry MAXMIN=1440 LOGFILE=$1 declare -ax vect echo "Inizializzazione $(date)" for (( i=0 ; $i<$MAXMIN ; i++ )) ; do vect[$i]=0 ; done echo "Analisi File $(date)" IFS="," while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 do minute=$(echo $a4|awk -F: { print $3} |sed s/^0*//g) awk sed hour=$(echo $a4|awk -F: { print $2} |sed s/^0*//g) sed if [ "$minute." == "." ]; then minute=0; fi if [ "$hour." == "." ]; then hour=0; fi tmp_m=$(($hour*60)) minutes=$(($tmp_m+$minute)) vect[$minutes]=$((${vect[$minutes]}+1)) done < $LOGFILE echo "risultati $(date)" for ( i=0 ; $i<$MAXMIN ; i++ ) ; do echo -n "$i " echo ${vect[$i]} done echo "fine $(date)" ld12 - imolug pvb265
  21. 21. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do #!/bin/bash . thanks Larry MAXMIN=1440 LOGFILE=$1 declare -ax vect echo "Inizializzazione $(date)" for (( i=0 ; $i<$MAXMIN ; i++ )) ; do vect[$i]=0 ; done echo "Analisi File $(date)" IFS="," while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 do minute=$(echo $a4|awk -F: { print $3} |sed s/^0*//g) awk sed hour=$(echo $a4|awk -F: { print $2} |sed s/^0*//g) sed if [ "$minute." == "." ]; then minute=0; fi if [ "$hour." == "." ]; then hour=0; fi tmp_m=$(($hour*60)) minutes=$(($tmp_m+$minute)) vect[$minutes]=$((${vect[$minutes]}+1)) done < $LOGFILE echo "risultati $(date)" for ( i=0 ; $i<$MAXMIN ; i++ ) ; do echo -n "$i " echo ${vect[$i]} done echo "fine $(date)" ld12 - imolug pvb265
  22. 22. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do #!/bin/bash . thanks Larry MAXMIN=1440 LOGFILE=$1 declare -ax vect echo "Inizializzazione $(date)" for (( i=0 ; $i<$MAXMIN ; i++ )) ; do vect[$i]=0 ; done echo "Analisi File $(date)" IFS="," while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 do minute=$(echo $a4|awk -F: { print $3} |sed s/^0*//g) awk sed hour=$(echo $a4|awk -F: { print $2} |sed s/^0*//g) sed if [ "$minute." == "." ]; then minute=0; fi if [ "$hour." == "." ]; then hour=0; fi tmp_m=$(($hour*60)) minutes=$(($tmp_m+$minute)) vect[$minutes]=$((${vect[$minutes]}+1)) done < $LOGFILE echo "risultati $(date)" for ( i=0 ; $i<$MAXMIN ; i++ ) ; do echo -n "$i " echo ${vect[$i]} done echo "fine $(date)" ld12 - imolug pvb265
  23. 23. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do 8000 . thanks Larry 7000 6000 5000 f(x) = 4.63x - 0.06 4000 native 3000 Linear (native) 2000 1000 0 123,000 183,000 363,000 423,000 483,000 663,000 723,000 783,000 963,000 1,143,000 3,000 63,000 243,000 303,000 543,000 603,000 843,000 903,000 1,023,000 1,083,000 1,203,000 1,263,000 1,323,000 1,383,000 1,443,000 50 minutes for 600.000 requests still no answer you gotta fired ld12 - imolug pvb265
  24. 24. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter 1 #!/bin/bash .. basics by examples MAXMIN=1440 .. not to do LOGFILE=$1 . thanks Larry declare -ax vect 2 echo "Inizializzazione $(date)" for (( i=0 ; $i<$MAXMIN ; i++ )) ; do vect[$i]=0 ; done 2 echo "Analisi File $(date)" IFS="," while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 do 3 minute=$(echo $a4|awk -F: { print $3} |sed s/^0*//g) echo awk sed 3 hour=$(echo $a4|awk -F: { print $2} |sed s/^0*//g) echo sed if [ "$minute." == "." ]; then minute=0; fi if [ "$hour." == "." ]; then hour=0; fi tmp_m=$(($hour*60)) minutes=$(($tmp_m+$minute)) vect[$minutes]=$((${vect[$minutes]}+1)) done < $LOGFILE 2 echo "risultati $(date)" for ( i=0 ; $i<$MAXMIN ; i++ ) ; do 1 echo -n "$i " 1 echo ${vect[$i]} done 2 echo "fine $(date)" ld12 - imolug pvb265
  25. 25. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter 1 #!/bin/bash .. basics by examples MAXMIN=1440 .. not to do LOGFILE=$1 . thanks Larry declare -ax vect 2 echo "Inizializzazione $(date)" for (( i=0 ; $i<$MAXMIN ; i++ )) ; do vect[$i]=0 ; done 2 echo "Analisi File $(date)" IFS="," while read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 do minute=$(echo $a4|awk -F: { print $3} |sed s/^0*//g) echo awk sed fork/exec → 2880+9 + 6N 3 3 hour=$(echo $a4|awk -F: { print $2} |sed s/^0*//g) echo sed if [ "$minute." == "." ]; then minute=0; fi line read → N if [ "$hour." == "." ]; then hour=0; fi tmp_m=$(($hour*60)) minutes=$(($tmp_m+$minute)) vect[$minutes]=$((${vect[$minutes]}+1)) done < $LOGFILE 2 echo "risultati $(date)" f(N)=6N+K for ( i=0 ; $i<$MAXMIN ; i++ ) ; do 1 echo -n "$i " 1 echo ${vect[$i]} done 2 echo "fine $(date)" ld12 - imolug pvb265
  26. 26. needs that lead to the camel LD12 faster wayld12 - imolug pvb265
  27. 27. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry AngelSpot (@mod186k1) says: why dont in PERL? ld12 - imolug pvb265
  28. 28. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter #!/usr/bin/perl -w .. basics by examples .. not to do my $MAXMIN=1440; . thanks Larry my $LOGFILE=shift(); my @vect; print "Inizializzazione ".qx/date/; for ( my $i=0 ; $i<$MAXMIN ; $i++ ) { $vect[$i]=0; } print "Analisi File ".qx/date/; open FILE, "<", $LOGFILE or die $!; while (<FILE>) { my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); my $minutes=$hour*60+$minute; $vect[$minutes]++; } close (FILE); print "risultati ".qx/date/; for ( my $j=0 ; $j<$MAXMIN ; $j++ ) { printf "%s %sn",$j,$vect[$j]; } print "fine ".qx/date/; ld12 - imolug pvb265
  29. 29. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter #!/usr/bin/perl -w .. basics by examples .. not to do my $MAXMIN=1440; . thanks Larry my $LOGFILE=shift(); my @vect; print "Inizializzazione ".qx/date/; for ( my $i=0 ; $i<$MAXMIN ; $i++ ) { $vect[$i]=0; } print "Analisi File ".qx/date/; open FILE, "<", $LOGFILE or die $!; while (<FILE>) { my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); my $minutes=$hour*60+$minute; $vect[$minutes]++; } close (FILE); print "risultati ".qx/date/; for ( my $j=0 ; $j<$MAXMIN ; $j++ ) { printf "%s %sn",$j,$vect[$j]; } print "fine ".qx/date/; ld12 - imolug pvb265
  30. 30. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter #!/usr/bin/perl -w .. basics by examples .. not to do my $MAXMIN=1440; . thanks Larry my $LOGFILE=shift(); my @vect; print "Inizializzazione ".qx/date/; for ( my $i=0 ; $i<$MAXMIN ; $i++ ) { $vect[$i]=0; } print "Analisi File ".qx/date/; open FILE, "<", $LOGFILE or die $!; while (<FILE>) { my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); my $minutes=$hour*60+$minute; $vect[$minutes]++; } close (FILE); print "risultati ".qx/date/; for ( my $j=0 ; $j<$MAXMIN ; $j++ ) { printf "%s %sn",$j,$vect[$j]; } print "fine ".qx/date/; ld12 - imolug pvb265
  31. 31. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter #!/usr/bin/perl -w .. basics by examples .. not to do my $MAXMIN=1440; . thanks Larry my $LOGFILE=shift(); my @vect; print "Inizializzazione ".qx/date/; for ( my $i=0 ; $i<$MAXMIN ; $i++ ) { $vect[$i]=0; } print "Analisi File ".qx/date/; open FILE, "<", $LOGFILE or die $!; while (<FILE>) { my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); my $minutes=$hour*60+$minute; $vect[$minutes]++; } close (FILE); print "risultati ".qx/date/; for ( my $j=0 ; $j<$MAXMIN ; $j++ ) { printf "%s %sn",$j,$vect[$j]; } print "fine ".qx/date/; ld12 - imolug pvb265
  32. 32. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry 8000 7000 6000 5000 f(x) = 4.63x - 0.06 4000 native Linear (native) 3000 perl 2000 Linear (perl) 1000 f(x) = 0.02x + 0.44 0 68,000 132,000 196,000 388,000 452,000 516,000 708,000 772,000 836,000 1,028,000 1,092,000 1,156,000 1,220,000 1,284,000 1,348,000 1,412,000 4,000 260,000 324,000 580,000 644,000 900,000 964,000 only 8 seconds for 600.000 requests just in time analisys came true ld12 - imolug pvb265
  33. 33. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry 8000 7000 6000 5000 f(x) = 4.63x - 0.06 4000 native Linear (native) 3000 perl 2000 f(x)=mx+q Linear (perl) 1000 f(x) = 0.02x + 0.44 0 fnative(x)=4,63x – 0,06 68,000 132,000 196,000 388,000 452,000 516,000 708,000 772,000 836,000 1,028,000 1,092,000 1,156,000 1,220,000 1,284,000 1,348,000 1,412,000 4,000 260,000 324,000 580,000 644,000 900,000 964,000 fperl(x)=0,02x – 0,44 4,63/0,02=231,5 only 8 seconds for 600.000 requests just in time analisys came true ld12 - imolug pvb265
  34. 34. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Returntest(5.000.000) 74.31 53.02 156.24 0.42 Functest(5.000.000) 63.85 53.84 106.24 0.39 file_line_test 9.53 27.87 9.88 1.50 file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  35. 35. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 Perform two nested loops, the outer loop of 500.000 iterations index_test(1.000.000) 17.64 26.49 23.83 1.44 and the inner of 10 iterations nested_int_test(23) 43.55 84.95 27.69 0.09 Nested Loops Returntest(5.000.000) 74.31 53.02 156.24 0.42 Functest(5.000.000) 63.85 53.84 106.24 0.39 file_line_test 9.53 27.87 9.88 1.50 file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  36. 36. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 Write 1.000.000 elements into hash-table and read then nested_int_test(23) 43.55 84.95 27.69 0.09 back Hash Table Returntest(5.000.000) 74.31 53.02 156.24 0.42 Functest(5.000.000) 63.85 53.84 106.24 0.39 file_line_test 9.53 27.87 9.88 1.50 file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  37. 37. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Five level of nested loops each of 23 iteration and at each level some simple arithmetic operation Returntest(5.000.000) 74.31 53.02 156.24 0.42 on a local variable Functest(5.000.000) 63.85 53.84 106.24 0.39 Nested Loops + Arithmetics on file_line_test 9.53 27.87 9.88 1.50 Local Vars file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  38. 38. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Returntest(5.000.000) 74.31 53.02 156.24 0.42 Test the cost of multiple argument return by performing 5.000.000 Functest(5.000.000) 63.85 106.24 Function call which return 53.84 0.39 Arguments unpacked into local variables file_line_test 9.53 27.87 9.88 1.50 Return Arguments file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  39. 39. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Returntest(5.000.000) 74.31 53.02 156.24 0.42 Test the cost of function calls by Performing 5.000.000 function calls Functest(5.000.000) 63.85 106.24 with one integer argument which 53.84 0.39 returns that argument file_line_test 9.53 27.87 9.88 1.50 Functions Calling file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  40. 40. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Returntest(5.000.000) 74.31 53.02 156.24 0.42 Functest(5.000.000) 63.85 53.84 106.24 0.39 file_line_test 9.53 27.87 9.88 1.50 Time spent opening the file and reading it line by line file_line_split_test 44.80 n/a 35.35 7.28 Reading File file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  41. 41. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Returntest(5.000.000) 74.31 53.02 156.24 0.42 Functest(5.000.000) 63.85 53.84 106.24 0.39 Reading Line by Line file_line_test 9.53 27.87 9.88 1.50 and Splitting file_line_split_test 44.80 n/a 35.35 7.28 Time spent opening the file and reading it line by line splitting each file_line_re_test 294.83 n/a 43.86 n/a line in token vector http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  42. 42. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 Returntest(5.000.000) 74.31 53.02 156.24 0.42 Reading Line by Line Functest(5.000.000) 63.85 53.84 106.24 0.39 and Splitting + Conditional Operations file_line_test 9.53 27.87 9.88 1.50 Time spent opening the file and file_line_split_test 44.80 n/a 35.35 7.28 reading it line by line, splitting each line in token vector with simple conditional analisys and file_line_re_test 294.83 n/a 43.86 n/a assegnation to local variables http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  43. 43. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way Python Ruby Perl C .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do Version 1.5.2 1.4.5 5.0pl5sv3 egcs-1.1.2 . thanks Larry GC Style RefCount GC RefCount None Tested-on 2000-07-19 2000-07-19 2001-04-18 2001-04-18 loop_test(500.000) 33.94 17.16 18.95 0.16 index_test(1.000.000) 17.64 26.49 23.83 1.44 nested_int_test(23) 43.55 84.95 27.69 0.09 reding file, Returntest(5.000.000) 74.31 53.02 156.24 0.42 manipulating strings, Functest(5.000.000) 63.85 53.84 106.24 0.39 loops and operations file_line_test 9.53 27.87 9.88 1.50 file_line_split_test 44.80 n/a 35.35 7.28 file_line_re_test 294.83 n/a 43.86 n/a http://dj1.willowmail.com/~jeske/Projects/ScriptPerf/ ld12 - imolug pvb265
  44. 44. needs that lead to the camel LD12 faster way Perl genesisld12 - imolug pvb265
  45. 45. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry Larry Wall 1954 bachelors degree in Natural and Artificial Languages Practical Extraction and Report Language Pathologically Eclectic Rubbish Lister Laziness, Impatience and Hubris 1987 http://www.linuxjournal.com/article/3394 ld12 - imolug pvb265
  46. 46. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Naming it Perl Practical Extraction and Report Language .. basics by examples .. not to do perl / Perl programm/Language . thanks Larry imperfect ”Perl was never designed to be perfect” adaptive “Over-specialization is only as good as your ecological niche” Perl 1.0 18 december 1987 newsgroup: comp.sources.misc Perl 2.0 1988 feature: better regular expression engine Perl 3.0 1989 feature: binary data streams Perl 4.0 1991 well documented, published Programming Perl (aka Camel Book) Perl 5.000 17 october 1994 extending the language without modifying the core interpreter Perl 5.001 13 march 1995 CPAN 26 october 1995 comprehensive perl archive network Perl 5.002 29 february 1996 feature: subroutine Perl 5.003 25 june 1996 security release Perl 5.004 15 may 1997 Perl 5.005 22 july 1998 http://www.linuxjournal.com/article/3394 ld12 - imolug pvb265
  47. 47. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Naming it Perl Practical Extraction and Report Language .. basics by examples .. not to do perl / Perl programm/Language . thanks Larry imperfect ”Perl was never designed to be perfect” adaptive “Over-specialization is only as good as your ecological niche” Perl 5.6 22 march 2000 feature: 64bit support, unicode, large file support Perl 6.0 19 july 2000 first announced by Larry in “State of the Onion 2000” talk Perl 5.10 18 december 2007 20th anniversary Perl 5.12 now http://www.linuxjournal.com/article/3394 ld12 - imolug pvb265
  48. 48. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Naming it Perl Practical Extraction and Report Language .. basics by examples .. not to do perl / Perl programm/Language . thanks Larry imperfect ”Perl was never designed to be perfect” adaptive “Over-specialization is only as good as your ecological niche” Perl history realease from 1.0 to 5.12 (6.0) main characteristics text-processing language modular glues for interstices UNICODE to be worldwide useful flexible http://www.linuxjournal.com/article/3394 ld12 - imolug pvb265
  49. 49. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Naming it Perl Practical Extraction and Report Language .. basics by examples .. not to do perl / Perl programm/Language . thanks Larry imperfect ”Perl was never designed to be perfect” adaptive “Over-specialization is only as good as your ecological niche” Perl history realease from 1.0 to 5.12 (6.0) main characteristics text-processing language modular gluesthe interstices for only POST-MODERN flexible UNICODE to be worldwide useful language http://www.linuxjournal.com/article/3394 ld12 - imolug pvb265
  50. 50. needs that lead to the camel LD12 faster way compiler vs interpreterld12 - imolug pvb265
  51. 51. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry A compiler is a program that reads code written in one source language and translate it into the same written in a second language ld12 - imolug pvb265
  52. 52. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples position := initial + rate * 60 .. not to do . thanks Larry ld12 - imolug pvb265
  53. 53. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position initial + rate * 60 ld12 - imolug pvb265
  54. 54. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position + initial rate * 60 ld12 - imolug pvb265
  55. 55. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position + initial * rate 60 ld12 - imolug pvb265
  56. 56. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position + initial * rate 60 ld12 - imolug pvb265
  57. 57. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position + initial * rate 60 syntax check syntax check optimization optimization executable execute ld12 - imolug pvb265
  58. 58. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position + initial * rate 60 compiler interpreter syntax check syntax check optimization optimization executable execute ld12 - imolug pvb265
  59. 59. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples := .. not to do . thanks Larry position + initial * rate 60 compiler like Java interpreter syntax check syntax check syntax check optimization optimization optimization bytecode executable VM per SO execute execute ld12 - imolug pvb265
  60. 60. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry compiler C C++ Pascal PL/1 like Java Java interpreter Bash Basic Lisp Javascript ld12 - imolug pvb265
  61. 61. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry compiler C C++ Pascal PL/1 like Java Java interpreter Perl Bash Basic Lisp Javascript ld12 - imolug pvb265
  62. 62. needs that lead to the camel LD12 faster way basics by examplesld12 - imolug pvb265
  63. 63. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry We cant condense the specifications of a language in a few slides, but You can fall in love seeing some simple examples. ld12 - imolug pvb265
  64. 64. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction ld12 - imolug pvb265
  65. 65. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction dynamically typed undef value my $MAXMIN=1440; my $j=0; my $name=”Valerio”; ld12 - imolug pvb265
  66. 66. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction @array %hash my @vect; my %vect; my $vect[$i]=0; my %vect{sun}=sunday; my %vect{mon}=monday; foreach $element (@vect) { foreach $key (keys %vect) { print “$elementn”; print “$key = $vect{$key}n”; } } print scalar(@vect); ld12 - imolug pvb265
  67. 67. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction $_ default input $! current error $$ process number $ARGV number of parameter @ARGV parameter @_ subroutine parameter open FILE, "<", $LOGFILE or die $!; my @field=split(,,$_); ld12 - imolug pvb265
  68. 68. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction perl in line execution of an interpreter script self interpreting >perl -e “print $$; print Hi pvb265!; ”; >cat test2.pl print $$; >cat test3.pl print Hi pvb265; #!/usr/bin/perl print $$; >perl test2.pl print Hi pvb265; >test3.pl ld12 - imolug pvb265
  69. 69. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction if (condition) { code } elsif (condition) { code } else { code } ; for (start,condition,increment) {code}; while (condition) {code}; for ( my $i=0 ; $i<$MAXMIN ; $i++ ) { $vect[$i]=0; }; while (<FILE>) { print $_; } if ( $tmp /^0101/ ) { print “matched”; } print “matched” if ( $tmp /^0101/ ); ld12 - imolug pvb265
  70. 70. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction vector = split(char,string); chomp($_); string =~ s/old/new/g; my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); $d0 =~ s/00/1/g; ld12 - imolug pvb265
  71. 71. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction close(filehandler); open filehandler, mode, filename; open FILE, "<", $LOGFILE or die $!; while (<FILE>) { my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); my $minutes=$hour*60+$minute; $vect[$minutes]++; } open FILE, "<", $LOGFILE or die $!; close (FILE); @lines = <FILE>; close (FILE); Foreach (@lines) { my @field=split(,,$_); my ($d0, $hour, $minute, $d1)=split(:,$field[3]); my $minutes=$hour*60+$minute; $vect[$minutes]++; } ld12 - imolug pvb265
  72. 72. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter Data Type Data Structure .. basics by examples .. not to do Predefined Variable Running . thanks Larry Loop and Condition String Manipulation IO function System Interaction system(cmdstring); `cmdstring`; qx/cmdstring/; my $cmd = “generatex509 pvb265”; system($cmd); print $?; my $cmd = “generatex509 pvb265”; @lines=`$cmd`; print @lines; print $?; my $cmd = “generatex509 pvb265”; @lines=qx/$cmd/; print @lines; print $?; ld12 - imolug pvb265
  73. 73. needs that lead to the camel LD12 faster way not to dold12 - imolug pvb265
  74. 74. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry never put sands in your favorite diesel engine! ld12 - imolug pvb265
  75. 75. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry also Perl may appear slow if U ... choose a slow algorithm dont properly use structured data Huge array of array of array... Huge hash of array of hash... LW Doing linear scans over an associative array is like trying to club someone to death with a loaded Uzi dont use regexps ld12 - imolug pvb265
  76. 76. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry also Perl may appear slow if U ... choose a slow algorithm hexadecimal → decimal perl -eprint map {hex $_} "547261aa696e6720ff74796c652f6dff" =~ /(....)/g; perl -eprint unpack "n*",pack "H*", "547261aa696e6720ff74796c652f6dff"; 21618 25002 26990 26400 65396 31084 25903 28159 ld12 - imolug pvb265
  77. 77. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry also Perl may appear slow if U ... choose a slow algorithm hexadecimal → decimal perl -eprint map {hex $_} "547261aa696e6720ff74796c652f6dff" =~ /(....)/g; valeriobalbi$ perl -MO=Terse -eprint map {hex $_} "54726164696e67207374796c652f6d61" =~ /(....)/g; LISTOP (0x102ff7e20) leave [1] OP (0x102f02f90) enter COP (0x102ff7dd0) nextstate LISTOP (0x102ffbbd0) print OP (0x102ffbc10) pushmark LOGOP (0x102ffbb60) mapwhile [3] LISTOP (0x102ffba80) mapstart OP (0x102ffbac0) pushmark UNOP (0x102ffbba0) null UNOP (0x102ff2ef0) null LISTOP (0x102f09350) scope OP (0x102f1f020) null [181] UNOP (0x102f09940) hex [2] UNOP (0x102f092a0) null [15] PADOP (0x102f02640) gvsv GV (0x7fdcf1803e28) *_ PMOP (0x102f09410) match SVOP (0x102f094d0) const [4] PV (0x7fdcf1829070) "54726164696e67207374796c652f6d61" -e syntax OK ld12 - imolug pvb265
  78. 78. a genda needs that lead to the camel LD12 . scenario . canonical way . faster way .. perl genesis .. compiler vs interpreter .. basics by examples .. not to do . thanks Larry also Perl may appear slow if U ... choose a slow algorithm hexadecimal → decimal perl -eprint unpack "n*",pack "H*", "547261aa696e6720ff74796c652f6dff"; valeriobalbi$ perl -MO=Terse -eprint unpack "n*",pack "H*", "547261aa696e6720ff74796c652f6dff"; LISTOP (0x7fd692cfbab0) leave [1] OP (0x7fd692c02f90) enter COP (0x7fd692c1f040) nextstate LISTOP (0x7fd692c09430) print OP (0x7fd692cfba80) pushmark LISTOP (0x7fd692c093c0) unpack OP (0x7fd692c09400) null [3] SVOP (0x7fd692c02640) const [2] PV (0x7fd693029058) "n*" LISTOP (0x7fd692c094d0) pack [1] OP (0x7fd692cf2ef0) pushmark SVOP (0x7fd692c092a0) const [3] PV (0x7fd693029070) "H*" SVOP (0x7fd692c09350) const [4] PV (0x7fd693029088) "547261aa696e6720ff74796c652f6dff" -e syntax OK ld12 - imolug pvb265
  79. 79. needs that lead to the camel LD12 thanks Lar r y thanks Angel Im not fired!ld12 - imolug pvb265
  80. 80. a genda . scenario .. not to do . faster wayld12 - imolug .. perl genesis . thanks Larry . canonical way .. basics by examples .. compiler vs interpreterpvb265 0 500 1000 1500 2000 2500 3000 00.02.00 00.44.00 01.26.00 02.08.00 02.50.00 03.32.00 04.14.00 04.56.00 05.38.00 06.20.00 07.02.00 07.44.00 08.26.00 09.08.00 09.50.00 10.32.00 11.14.00 11.56.00 12.38.00 13.20.00 14.02.00 14.44.00 15.26.00 16.08.00 16.50.00 17.32.00 18.14.00 18.56.00 ….back to the original problem 19.38.00 20.20.00 21.02.00 21.44.00 22.26.00 23.08.00 23.50.00 req needs that lead to the camel LD12
  1. A particular slide catching your eye?

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

×