A short introduction to the perl debugger's basic commands for executing code, examining data structures. Includes examples of hardwiring breakpoints, tracing sections of code, debugging regexen.
The $path to knowledge: What little it take to unit-test Perl.Workhorse Computing
Metadata-driven lazyness, Perl, and Jenkins provide a nice mix for automated testing. With Perl the only thing required to start testing is a files path, from there the possibilities are endless. Using Symbol's qualify_to_ref makes it easy to validate @EXPORT & @EXPORT_OK, knowing the path makes it easy to use "perl -wc" to get diagnostics.
The beautiful thing is all of it can be lazy... er, "automated". And repeatable. And simple.
Building a Perl5 smoketest environment in Docker using CPAN::Reporter::Smoker. Includes an overview of "smoke testing", shell commands to contstruct a hybrid environment with underlying O/S image and data volumes for /opt, /var/lib/CPAN. This allows maintaining the Perly smoke environemnt without having to rebuild it.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
Overview of Trampoline Objects in Perl with examples for lazy construction, lazy module use, added sanity checks. This version includes corrections from the original presented at OSCON 2013 and comments.
We have all seen repetitive code, maintained by cut+paste, that creates an object, calls a method, checks a return, calls a method, checks a return... all of it difficult to maintain because of its sheer size.
Object::Exercise replaces the pasted loops with data-driven code, the operation controlled by a data structure of methods, arguments, and expected return values. This replaces cut+paste with declarative data.
This talk describes O::E and shows a few ways to apply it for testing the MadMongers' Adventure game.
This talk describes refactoring FindBin::libs from Perl5 to Raku: breaking the module up into functional pieces, writing the tests using Raku, testing and releasing the module with mi6.
Variable interpolation is a standard way to BASH your head. This talk looks at interpolation, eval, ${} handling and "set -vx" to debug basic variable handling.
The $path to knowledge: What little it take to unit-test Perl.Workhorse Computing
Metadata-driven lazyness, Perl, and Jenkins provide a nice mix for automated testing. With Perl the only thing required to start testing is a files path, from there the possibilities are endless. Using Symbol's qualify_to_ref makes it easy to validate @EXPORT & @EXPORT_OK, knowing the path makes it easy to use "perl -wc" to get diagnostics.
The beautiful thing is all of it can be lazy... er, "automated". And repeatable. And simple.
Building a Perl5 smoketest environment in Docker using CPAN::Reporter::Smoker. Includes an overview of "smoke testing", shell commands to contstruct a hybrid environment with underlying O/S image and data volumes for /opt, /var/lib/CPAN. This allows maintaining the Perly smoke environemnt without having to rebuild it.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
Overview of Trampoline Objects in Perl with examples for lazy construction, lazy module use, added sanity checks. This version includes corrections from the original presented at OSCON 2013 and comments.
We have all seen repetitive code, maintained by cut+paste, that creates an object, calls a method, checks a return, calls a method, checks a return... all of it difficult to maintain because of its sheer size.
Object::Exercise replaces the pasted loops with data-driven code, the operation controlled by a data structure of methods, arguments, and expected return values. This replaces cut+paste with declarative data.
This talk describes O::E and shows a few ways to apply it for testing the MadMongers' Adventure game.
This talk describes refactoring FindBin::libs from Perl5 to Raku: breaking the module up into functional pieces, writing the tests using Raku, testing and releasing the module with mi6.
Variable interpolation is a standard way to BASH your head. This talk looks at interpolation, eval, ${} handling and "set -vx" to debug basic variable handling.
Starting with the system calll "getrusage", this returns synchronous, process-level information, mainly max RSS used. This talk describes the output from getrusage, the rusage formatting utility in ProcStats, and several examples of using it to examine time and memory use.
Optional first & final outputs to give baseline and total status, differencing avoids extraneous output, and user messages allow arbitrary stat's and tracking content.
The combination makes this nice for tracking both long-lived and shorter, more intensive processing.
Face it, backticks are a pain. BASH $() construct provides a simpler, more effective approach. This talk uses examples from automating git branches and command line processing with getopt(1) to show how $() works in shell scripts.
A few general pointers for Perl programmers starting out to write tests using Perl6. This describes a few of the differences in handling arrays vs. hashes, comparing objects, flattening, and value vs. immutable object contents.
Perl6 regular expression ("regex") syntax has a number of improvements over the Perl5 syntax. The inclusion of grammars as first-class entities in the language makes many uses of regexes clearer, simpler, and more maintainable. This talk looks at a few improvements in the regex syntax and also at how grammars can help make regex use cleaner and simpler.
PHP 8.0 comes with many long-awaited features: A just-in-time compiler, attributes, union types, and named arguments are just a small part of the list. As a major version, it also includes some backward-incompatible changes, which are centered around stricter error handling and enhanced type safety. Let's have an overview of the important changes in PHP 8.0 and how they might affect you!
PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications, and things to watch out for when using Enums.
PHP 8.0 is expected to be released by the end of the year, so it’s time to take a first look at the next major version of PHP. Attributes, union types, and a just-in-time compiler are likely the flagship features of this release, but there are many more improvements to be excited about. As PHP 8.0 is a major version, this release also includes backwards-incompatible changes, many of which are centered around stricter error handling and more type safety.
This talk will discuss new features already implemented in PHP 8, backwards-compatibility breaks to watch out for, as well as some features that are still under discussion.
November Camp - Spec BDD with PHPSpec 2Kacper Gunia
My slides on PHPSpec 2 from Symfony November Camp Stockholm.
www.symfony.se/november-camp/
More Domain-Driven Design related content at: https://domaincentric.net/
Starting with the system calll "getrusage", this returns synchronous, process-level information, mainly max RSS used. This talk describes the output from getrusage, the rusage formatting utility in ProcStats, and several examples of using it to examine time and memory use.
Optional first & final outputs to give baseline and total status, differencing avoids extraneous output, and user messages allow arbitrary stat's and tracking content.
The combination makes this nice for tracking both long-lived and shorter, more intensive processing.
Face it, backticks are a pain. BASH $() construct provides a simpler, more effective approach. This talk uses examples from automating git branches and command line processing with getopt(1) to show how $() works in shell scripts.
A few general pointers for Perl programmers starting out to write tests using Perl6. This describes a few of the differences in handling arrays vs. hashes, comparing objects, flattening, and value vs. immutable object contents.
Perl6 regular expression ("regex") syntax has a number of improvements over the Perl5 syntax. The inclusion of grammars as first-class entities in the language makes many uses of regexes clearer, simpler, and more maintainable. This talk looks at a few improvements in the regex syntax and also at how grammars can help make regex use cleaner and simpler.
PHP 8.0 comes with many long-awaited features: A just-in-time compiler, attributes, union types, and named arguments are just a small part of the list. As a major version, it also includes some backward-incompatible changes, which are centered around stricter error handling and enhanced type safety. Let's have an overview of the important changes in PHP 8.0 and how they might affect you!
PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications, and things to watch out for when using Enums.
PHP 8.0 is expected to be released by the end of the year, so it’s time to take a first look at the next major version of PHP. Attributes, union types, and a just-in-time compiler are likely the flagship features of this release, but there are many more improvements to be excited about. As PHP 8.0 is a major version, this release also includes backwards-incompatible changes, many of which are centered around stricter error handling and more type safety.
This talk will discuss new features already implemented in PHP 8, backwards-compatibility breaks to watch out for, as well as some features that are still under discussion.
November Camp - Spec BDD with PHPSpec 2Kacper Gunia
My slides on PHPSpec 2 from Symfony November Camp Stockholm.
www.symfony.se/november-camp/
More Domain-Driven Design related content at: https://domaincentric.net/
Perl is a programming language which can be used for a large variety of tasks. A typical simple use of Perl would be for extracting information from a text file and printing out a report or for converting a text file into another form. But Perl provides a large number of tools for quite complicated problems, including systems programming.
Programs written in Perl are called Perl scripts, whereas the term the perl program refers to the system program named perl for executing Perl scripts.
If you have used shell scripts or awk or sed or similar (Unix) utilities for various purposes, you will find that you can normally use Perl for those and many other purposes, and the code tends to be more compact. And if you haven't used such utilities but have started thinking you might have need for them, then perhaps what you really need to learn is Perl instead of all kinds of futilities.
Perl is implemented as an interpreted (not compiled) language. Thus, the execution of a Perl script tends to use more CPU time than a corresponding C program, for instance. On the other hand, computers tend to get faster and faster, and writing something in Perl instead of C tends to save your time.
Why Perl ?
Perl is still used in today's world as like
data mining / statistical analysis - the perl regex engine, even if slightly outdated, (PCRE, a spinned off library, tops it up in any possibile way and it's the default PHP engine) is still good for simple analysis
UNIX system administration - Perl shall always be installed on UNIX.
You can count on it being readily available even on Mac OS X.
network prototyping - many core network experts learned Perl when it was all the rage; and they still do their proofs-of-concept with it.
security - many security experts, too, need fast prototyping. (and fast automated fixes) Perl can, and does, cover for that.
Benefits of Perl Certification-
The Perl Programming certificate series comprises four courses that take students from a complete beginner to an advanced level that includes use of reusable code and creation of objects for network-based applications.
Upon completion of this certificate program, you will be able to:
Create Perl scripts that use variables, conditionals, interpolation, arrays, lists, hashes, subroutines, loops, formatted printing, data mapping, and sorting.
Implement Perl scripts that work with external files.
Utilize regular expressions, exception handling, multiprocessing, objects, and complex data structures.
Develop applications that perform complex text processing, web page scraping and form handling, and database interaction.
Navigate third-party code in the Comprehensive Perl Archive Network (CPAN) and use it in your own applications.
Contact us today to know more about Perl.
www.vibranttechnologies.co.in
Slides for my talk at SkyCon'12 in Limerick.
Here I've squeezed four talks into one, covering a lot of ground quickly, so I've included links to more detailed presentations and other resources.
Hiveminder - Everything but the Secret SauceJesse Vincent
Ten tools and techniques to help you:
Find bugs faster バグの検出をもっと素早く
Build web apps ウェブアプリの構築
Ship software ソフトのリリース
Get input from users ユーザからの入力を受けつける
Own the Inbox 受信箱を用意する
今日の話
BITS: Introduction to relational databases and MySQL - Schema designBITS
BITS training: Introduction to relational databases and MySQL - Module 3: Schema design.
See http://www.bits.vib.be/index.php?option=com_content&view=article&id=17204047:green-basics-of-databases&catid=81:training-pages&Itemid=190
Our new blog post featuring some common python programming patterns and their C++ equivalents is now up!
Leave us a comment below and let us know what you'd like to see covered in our future posts!
█ Read More
Technical Insights: Introduction to GraphQL|goo.gl/d7PyXH
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Data Con LA
This presentation will explore how Bloomberg uses Spark, with its formidable computational model for distributed, high-performance analytics, to take this process to the next level, and look into one of the innovative practices the team is currently developing to increase efficiency: the introduction of a logical signature for datasets.
Our Friends the Utils: A highway traveled by wheels we didn't re-invent. Workhorse Computing
Scalar::Util, List::Util, and List::MoreUtils provide simpler, cleaner, and faster solutions in XS for scalar introspection and list management than what is available in Pure Perl. This is a short introduction to the utilities and how they work with more recent Perl features like smart matching.
With all of the focus on OOP and frameworks, sometimes the utilities get ignored. These modules provide us with lightweight, simple, effective solutions to everyday problems, saving us all from reinventing the wheel. This talk looks at a several of the utilities and shows some of the less common ways they can save a lot of time.
Nonparametric statistics show up in all sorts of places with fuzzy, ranked, or labeled data. The techniques allow handling messy data with more robust results than assuming normality. This talk describes the basics of nonparametric analysis and shows some examples with the Kolomogrov-Smirnov test, one of the most commonly used.
perl often doesn't get updated because people don't have a way to know if their current code works with the new one. The problem is that they lack unit tests. This talk describes how simple it is to generate unit tests with Perl and shell, use them to automate solving problems like missing modules, and test a complete code base.
Using a base date, intervals, and ranges makes it easy to generate lookup tables for calendar intervals like annual or quarterly reports. The SQL for generating and searching the tables is made much easier using PG's built in range and interval types and more efficient with GiST indexes.
Performance benchmarks are all too often inaccurate. This talk introduces some things to look for in setting up and running benchmarks to make them effective.
A short description of the W-curve and its application to aligning genomic sequences. This includes a short introduction to the W-curve, example of SQL-based alignment of a crossover, suggestions for further work on its application.
This describes a Functional Programming approach to computing AWS Glacier "tree hash" values, hiding the tail-call elimination in Perl5 with a keyword and also shows how to accomplish the same result in Perl6.
This was the talk actually given at YAPC::NA 2016 by Dr. Conway and myself.
Implementing Glacier's Tree Hash using recursive, functional programming in Perl5. With Keyword::Declare we get clean syntax for tail-call elimination. Result is a simple, fast, functional solution.
Short introduction to the use of non-parametric statistical analysis for quality assessment, general robust analysis of data. Includes a short introduction to the normal distribution and requirements for parametric analysis, review of binomial and poisson distributions, examples of non-parametric data, and example of using Kolomogrov-Smirnov. Final sections include references.
Shared Object images in Docker: What you need is what you want.Workhorse Computing
Docker images require appropriate shared object files (".so") to run. Rather than assume Ubuntu has the correct lib's, use ldd to get a list and install the ones you know you need. This can reduce the underlying images from GB to a few MB.
Logical Volume Management ("LVM") on linux looks like a complicated mess at first. The basics are not all that hard, and some features like mirroring, dynamic space management, snapshots for stable backups, mirroring, and over-provisioning via thin volumes can save a lot of time and effort.
Storing all of the reply content is usually not possible: it may be dynamic. A proxy allows directing only the content that needs to be handled locally to the test server, other content can go to the cloud. The final step, closing the loop between client and server, requires wapping LWP::UserAgent to direct locally handled requests to the test server.
Testing web front ends is a pain, partly because we end up testing the back end with them. Selenium helps by automating the input, but the selenium driver code lacks high-level interfaces for things like "find_and_click" or "find_and_key". Adding these with a wrapper makes data-driven selenium testing via Object::Exercise easy.
The perl on most linux distros is a mess. Docker makes it easier to build and packge a local perl and applications. Problem is that Docker's manuals produce a mess of their own.
Distributing perl on top of Gentoo's stage3 distro, busybox, or nothing at all made good alternatives. This talk includes basics of setting up docker, building a local perl for it, and packaging perl or applications into images for use in containers.
Perl6 introduces a variety of tools for functional programming and writing readable code. Among them parameter declarations and lazy lists. This talk looks at how to get Perl6, where to find examples on RakudoCode, and how to use Perl6 functional tools for converting an algorithm from imperative to functional code, including parallel dispatch with the ">>" operator.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
1. Basics of perl -d
Steven Lembark
Workhorse Computing
lembark@wrkhors.com
2. Introducing Perl's Debugger
● Overview of the obvious uses, common commands.
● Few less obvious uses:
● Debugging regexen.
● Evaluating structure bloat.
● Some pitfalls and how to avoid them.
3. What is the Perl Debugger?
● The Perl debugger comes with perl, in fact it is perl.
● 'd' is built into perl's command line.
● It functions like a perly shell, evaluating source code
from files or the command line or executing
debugger commands.
● You also use perl d with profiling utilities like
NYTprof.
4. Smarter Than Your Average Code
● The most obvious thing you can do is walking code
to track down bugs.
● You can also test Perl syntax: just type it in.
● Use it as a “perly shell” when your oneliners run
into multiple lines or you have to eyeball data
structures between commands.
● Q&D interactive data mining.
● Good for examining data structures when writing
talks on data manglement or module guts.
5. The Basics: Getting In
● At the command $ perl d e 42;
line: perl d enters $ perl d foo.pm;
the debugger.
$ perl d bar;
● You can start it
'vanilla', with $ perl MDevel::Size d e foo;
modules to watch
startup, with code,
or using modules to
pull in utilities (e.g.
regex debugging).
6. Basics: The Prompt
● Once in you get the command prompt:
$ perl d e 42
Loading DB routines from perl5db.pl version 1.22
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(e:1): 42
DB<1>
● This is a “vanilla” session: there is no running code,
you can enter debugger commands, perl syntax.
● The single “<1>” indicate that this is the outermost
call level.
● The “1” says that this is the first command.
7. Executing Perl Statements
● Q: Who remembers what localtime returns?
● A: How to find out?
DB<1> x
localtime
0 31
1 31
2 15
3 15
4 5
5 111
6 3
7 165
8 1
DB<2>
● Notice that now I'm at command #2.
8. Gotchas
● Each command you type is run its own block.
● Lexical variables like “my $foo” will vanish.
● Local values like “local $” or “local $foo{ bar } = ...”
will also be unavailable after the line completes.
● You can put multiple statements onto a line with
semicolon separators.
● You can only input one line at a time.
● Cutandpaste of multiple lines won't work.
9. Debugger Commands
● These intentionally look pretty much like gdb.
● On the other hand, if you didn't grow up debugging C
code this may not help you much.
● The most common commands are for running code,
managing breakpoints (i.e. stopping code),
interrogating values.
● Please note: “q” gets you out.
● Not “quit”, ^C, ^D, or “getmeoutofhere!”.
10. Setting Up the Debugger
● You may want to edit your commands.
● Installing Term::ReadKey &Term::ReadLine.
● perl will use your .inputrc if you have one.
● For example, my .inputrc looks like:
set editing-mode vi
set show-all-if-ambiguous on
with allows ^[k to pull up the last line for editing.
● Check the doc's if you use Emacs.
11. Running Code
● Say some code blows up.
● You could just run it with “r” from the start.
● That is handy once to see where it blows up.
● Usually you want to stop at a particular place to see
why it blows up.
● You can continue to a line no or sub name with:
c 15
c call_foomatic
12. Stepping Code
● You can also watch the code one line at a time.
● “n” (“next”) steps over the subroutine calls.
● “s” (“step”) steps into the subroutine calls.
● “r” (“return”) goes back to the caller if you accidentally
step one level too deep.
● One really common combination:
● “c” to a subroutine that blows up.
● “n” to the point before it dies.
● “s” into the call that failed and see what happens.
13. Getting Out of a Hole: “r”
● Sometimes you 's' into the wrong sub (say a DBI
call).
● You don't want to abort the session.
● You don't want to “n” your way through DBI.
● Use “r” to return from the current call.
● This also shows you the return value passed back to
the caller.
● Nice for checking that what you expect gets returned.
● Beware if the structure is really large.
14. Stopping Code: Breakpoints
● Breakpoints stop the code.
● They can include a condition.
● Say the code blows up at line 842 with a non
reference value in $thingy after roughly 8_000
iterations.
● Set a breakpoint and continue:
<1> b 842 ! ref $thingy
<2> c
16. Hashes Are Lists to “x”
● Hashes look a little odd at first:
DB<8> x %a = map { $_ => [ 1 ] } ( 'a' .. 'c' )
0 'a'
1 ARRAY(0xc122a0)
0 1
2 'b'
3 ARRAY(0xb07fe0)
0 1
4 'c'
5 ARRAY(0xc122e8)
0 1
● They look exactly like the array: a list.
17. Hashref's Are Structures
● Examining a hashref shows it as key => value pairs:
DB<9> x %a
0 HASH(0xc47008)
'a' => ARRAY(0xc122a0)
0 1
'b' => ARRAY(0xb07fe0)
0 1
'c' => ARRAY(0xc122e8)
0 1
18. You Don't Always Want It All
● Occasionally you'll get something like:
0 ARRAY(0xc99050)
0 ARRAY(0xc99080)
0 ARRAY(0xc990b0)
0 ARRAY(0xc990e0)
0 ARRAY(0xc99110)
0 ARRAY(0xc99140)
empty array
DB<17>
● This was a structure that didn't fit onto the screen.
● Use “x” with a limit to display less of it.
19. Getting What You Need
● A digit following “x” limits the depth:
DB<26> $i = 'z'
DB<27> $a = $b = []
DB<28> for( 1 .. 100 ) { $b = $b->[0] = [], $b->[1] = ++$i }
DB<29> x 6 $a
0 ARRAY(0xc90e38)
0 ARRAY(0xc917f8)
0 ARRAY(0xc988e8)
0 ARRAY(0xc98af8)
0 ARRAY(0xc98a20)
0 ARRAY(0xc98b10)
1 'ad'
1 'ac'
1 'ab'
1 'aa'
20. Mining Large Data Structures
● x 2 $struct will show the top level, including hash
keys or offset lists.
● x 2 $struct>{ key } will show the single hash value.
● To walk through a structure in viewable chunks:
● x 2 $struct>{ key1 }{ key2 }
● See what matters, paste on the next key/offset and keep
looking:
● x 2 $struct>{ key1 }{ key2 }[ offset ]
21. You Are Here
● The “T” command provides a stack trace.
● Useful with hardwired breakpoints.
● They show the calling line numbers and values.
● Makes it easier to set breakpoints up the stack to see how
values are [mis]managed down the call stack.
● Viewing the code uses “l” and “v”.
● “l” (list) shows the next line to be executed.
● “v” (view) shows a small window around the line.
22. Finding Out What You Can Do
35: my $frag
36: = WCurve::Fragment->new
37: (
● “m” shows the 38:
39: );
FloatCyl => ( $base x $length ), $name
methods of an DB<1> n
Testify::(01-FloatCart-basic-geometry.t:41):
41: ok $frag eq $name, "Name: $frag ($name)";
object. DB<1> m $frag
add_skip_chain
carp
● Items with confess
converge_limit
looks_like_number
package via WCurve::Fragment: (""
prefixes are via
via
WCurve::Fragment:
WCurve::Fragment:
()
(0+
via WCurve::Fragment: (bool
inherited. via
via
WCurve::Fragment:
WCurve::Fragment:
(int
stop_offset
● Leading '(' is via
via
WCurve::Fragment: sum
WCurve::Fragment -> ArrayObj: (<=>
an overload. via
via
WCurve::Fragment -> ArrayObj: (cmp
WCurve::Fragment -> ArrayObj: DESTROY
via UNIVERSAL: DOES
via UNIVERSAL: VERSION
via UNIVERSAL: can
via UNIVERSAL: isa
23. Hardwired Breakpoints
● Because the perl debugger is written in perl, you can
also set “hardwired” breakpoints:
$DB::single = 1;
$DB::single = 1 unless ref $thingy;
$DB::single = 1 if $counter > @itemz;
● These can be useful in permanent code:
eval { … }
or do
{ print $@; $DB::single = 1; 0 };
24. Tracing Code
● Tracing code usually produces too much output.
● To turn on tracing use $DB::trace = 1.
● You can localize it to trace a code block.
● Add iflogic to trace code leading up to errors:
$DB::trace = 1 if ! ref $foo;
● One trick for restartable subs is to eval them and
trace the failures:
eval { foo } or do{ trace = 1; foo }
25. Ever Wonder How a Regex Works?
● The “re” module allows debugging regexen:
use re 'debug';
use re 'debugcolor';
● There is more info in “perldoc perldebug”.
● A monochrome example:
26. DB<7> do { use re 'debug'; $a = qr/ (w+) $/x; print 'this is a test' =~ /
$a/; }
Compiling REx " (w+) $"
Final program:
1: OPEN1 (3)
3: PLUS (5)
4: ALNUM (0)
5: CLOSE1 (7)
7: EOL (8)
8: END (0)
floating ""$ at 1..2147483647 (checking floating) stclass ALNUM plus minlen 1
Guessing start of match in sv for REx " (w+) $" against "this is a test"
Found floating substr ""$ at offset 14...
start_shift: 1 check_at: 14 s: 0 endpos: 14
Does not contradict STCLASS...
Guessed: match at offset 0
Matching REx " (w+) $" against "this is a test"
Matching stclass ALNUM against "this is a test" (14 chars)
0 <this is a >| 1:OPEN1(3)
0 <this is a >| 3:PLUS(5)
ALNUM can match 4 times out of 2147483647...
4 <this is a test>| 5: CLOSE1(7)
4 <this is a test>| 7: EOL(8)
failed...
...
1 <this is a t>| 5: CLOSE1(7)
1 <this is a t>| 7: EOL(8)
...
7 <this is a test>| 5: CLOSE1(7)
7 <this is a test>| 7: EOL(8)
failed...
...
10 <this is a test>| 3:PLUS(5)
ALNUM can match 4 times out of 2147483647...
14 <this is a test>| 5: CLOSE1(7)
14 <this is a test>| 7: EOL(8)
14 <this is a test>| 8: END(0)
Match successful!
test
DB<8>
27. Benchmarking Size
● Devel::Peek && Devel::Size show the contents and
size of structures inside of perl.
● There are lots of examples in Perl Memory
Manglement, which is mostly a session of
perl -Mdevel::Size -d -e 0;
● The advantage to dealing with this in the debugger is
being able to interactively query the sizes of sub
structures to see where bloat comes from.
28. Knowing When You're There
● The variable $^P will be true when code is running
in the debugger.
● This allows you to automatically set hardwired
breakpoints or verbosity:
my $max_verbose = $cmdline{ verbose } > 1 || $^P;
29. Spoon Feeding
● The debugger does not handle forks automatically.
● The problem is that multiple processes latch on to the tty
device files for input and output.
● You can set the display to a set of perinitialized ttys
(usually preopened xterm's).
● At that point you can switch to the alternate terminals to
handle each session.
30. Semiautomated Forks
● You can usually dodge the issue by simply not
forking in the debugger:
if( my $pid = $^P ? '' : fork )
{
# parent
}
elsif( defined $pid )
{
# child, debugger
}
else
{
die "Phorkafobia: $!";
}
31. A Modern Version
given( $^P ? '' : fork )
{
when( '' ) { ... }
when( undef ) { die "Phorkafobia: $!" }
my $child = wait;
# parent processes results.
}
32. Further Reference
● A always, perldoc is your friend.
● perldoc perldebug
● perldoc perlre
● Perldoc DB
● For examples of querying memory use:
● perldoc Devel::Peek
● perldoc Devel::Size
● http://www.slideshare.net/lembark/perl5memorymanglement