Re: My Perl journey begins
by hippo (Archbishop) on Aug 18, 2022 at 10:47 UTC
|
Welcome to the Monastery and the wider Perl world, oldB51. You've made a great start already.
It is likely that my debug tactic will be to print variables at various stages until the problem is found. This is usually easier than a formal debugger anyway.
I too am an advocate of liberal print/warn statements while debugging. However you may be unaware that Perl has its own built-in debugger which can you use at any time should you so wish. It is explained extensively in perldebug. See also the FAQ How do I debug my Perl programs?
I think I’m right in saying neither will in fact install on 64bit Macs. But - if this is the case - why does the installation begin. Surely cpanm knows what system it is trying to install into and should stop the process immediately with a polite message.
It does know the architecture but it doesn't necessarily know that any given module won't install there. That is in the gift of the module author and they may not know either. Many modules were originally written before 64-bit architectures were widely available, for example, and some have not kept pace with such developments. It might also be the case that it's just a bug and needs to be fixed.
Contrarily many modules will bail out early if it is attempted to install them on a platform which is known to be unsuitable. This is most often seen when a non-Perl pre-requisite is missing (a compiler, a system libarary, a third-party tool, etc.). You will probably come across one of these eventually.
| [reply] |
|
|
| [reply] |
Re: My Perl journey begins
by stevieb (Canon) on Aug 18, 2022 at 02:00 UTC
|
I suspect I will soon be seeking advice from Perl Monks - so many thanks in advance.
Welcome to the Monastery!
Feel free to ask all the questions you want. There are many, many Perl folk here who love to help, several with decades of experience.
Cheers, and have fun!
-stevieb
| [reply] |
Re: My Perl journey begins
by tobyink (Canon) on Aug 18, 2022 at 08:14 UTC
|
Padre development stagnated about a decade ago sadly. I've found Atom to be a good editor so far, but its corporate sponsor (Microsoft/Github) is abandoning it, so its future is a little uncertain at the moment. I do hear good things about vscode though.
Welcome to the site!
| [reply] |
Re: My Perl journey begins
by NERDVANA (Priest) on Aug 19, 2022 at 21:15 UTC
|
Back when I was doing Delphi, I vowed I would never use another language without an integrated debugger. But then I started web development (in Java and C++ actually) and realized that an integrated debugger isn't worth setting up when you're trying to debug incoming web requests. It can be done, but the hassle outweighs the benefit. So I got used to logging. And... logging can be so much better! If you have really good logging (as in, only logging the points of interest and variables of interest, and configurable log levels) on a complex algorithm, you can actually read the log faster than stepping through hundreds of method calls, or walking backward through massive data structures to figure out where the algorithm went wrong. This even carries over to JavaScript, where I've had times that the console.log was more useful than the built-in debugger. Especially when the file has been minified.
I've gotten the most use out of Log::Any. I wrote my own minimalist adapter for it Log::Any::Adapter::Daemontools which can change the log level on the fly in response to SIGUSR1 and SIGUSR2. And then I have written in-house Plack middleware that can change the log level depending on a browser cookie. (I might get that published some day) The end result is that I can set that secret cookie on my browser and then perform actions on the production system and see the full trace output even while other users are hitting the same server and generating minimal log output. (The log output stays in the server logs, so there isn't any security risk in this cookie as there would be if it pushed the logs to the browser.)
The other thing Perl has that kills the need for a debugger is nice easy unit testing. See Test::More or Test2. If you structure your program as a collection of small mostly-independent modules, you can wrap each of them with unit tests and work out all the bugs before you assemble them into anything complicated. It's amazing how few bugs I end up having in the main program if I've fully tested each of the components first. And there's always "perl -d" for debugging the unit tests, if the log wasn't enough. | [reply] |
|
|
I second your sentiment about print/log debugging plus testing.
For me personally is the debugger only helpful when dealing with badly documented foreign code, to figure out WHERE and HOW things happen, not necessarily what goes WRONG.
I.e. tests and logging are missing, and I can't figure out the flow by looking at the code.
(I also use the Perl-debugger as kind-of REPL to test code snippets, but that's not debugging)
To my chagrin are most of my colleagues trained from early on to develop with the debugger, because our tool of choice - Komodo - makes it very easy to set a breakpoint at the fringe of the actual code and step thru and see watch expressions.
Furthermore is F5 set to run inside the debugger, it's F6 for an independent run.
It's so interwoven, that they don't even know how to use perl -d and its commands. The keep talking about "Komodo's debugger", literally as if Active-State hacked an independent solution.
This, plus continuous automatic perl -c in the background with underlining of compilation errors (mostly forgotten my declarations) leads to a kind of "try and error" programming mentality.
Before I started for that client, newbies were told to copy-paste a "working" script and adapt it to their needs, Komodo would just help them underlining problems and help "debugging".
It's quite hard to convince them that the proactive use of test-suites and logging leads to better results.
It's basically a question of return of investment...
| [reply] [d/l] [select] |
Re: My Perl journey begins
by Discipulus (Canon) on Aug 18, 2022 at 09:24 UTC
|
Hello oldB51 and welcome to the monastery and to the wonderful world of Perl!
you can find interesting this recent thread: Workflow / Setup Questions where perl IDE are discussed.
See also RFC: Perl Learning Plan where I mention Modern Perl Book: worth to read even if not for beginners.
I loved a lot the ancient Perl Cookbook which can offer you a wide panorama about how many things Perl is good at (remember is an old book but many approaches presented here are basically still valid).
Pay attention to links posted by eyepopslikeamosquito: our best link collector :) (I try to mimicry them in my chaotic bibliotheca)
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] [select] |
|
|
Thanks for the response . Modern Perl is on my list. The IDE link is very useful…I had already tried BBEdit…an excellent text editor…but I decided on vscode.
However, I have seen several references to IntelliJ IDEA and decided to take the plunge. It is fantastic. I have some experience with its sister product CLion so didn’t require much convincing.
| [reply] |
|
|
I have some experience with its sister product CLion so didn’t require much convincing.
Yeah, their other products are almost identical. I use CLion for several projects as well (and Rider etc, etc). The awesome thing about their products is that they all allow you to install the same plugins. For example, CLion is what I use for C/C++ development, but it also allows the Perl plugin be installed, so I can work on my projects that include both C and Perl (such as this one) without having to have two IDEs open.
I've been a user of their software for a very long time now. Best part is, is that they have an Open Source License, so if you've got a viable Open Source project(s) published, you can apply for said license, and that allows you to use every single one of their products for free.
| [reply] |
Re: My Perl journey begins
by karlgoethebier (Abbot) on Aug 18, 2022 at 20:12 UTC
|
Some more probably useful stuff:
Best regards and have fun, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] |
|
|
| [reply] |
Re: My Perl journey begins
by ForgotPasswordAgain (Vicar) on Aug 20, 2022 at 06:09 UTC
|
Hmm, if you can begin your Perl journey two days ago... I can finally sign my old ass up for a TikTok account. #letsgo (or is tiktok outdated nowadays? sorry) | [reply] |
|
|
| [reply] |