Perl - Single stepping, Interaction

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Perl - Single stepping, Interaction

Post by Bob Hansen »

I am being forced (by myself, sometimes a tough boss) to get more familiar with Perl. I have installed it, created document classes, added tools to execute the current file, and one tool to "debug" buy using -d $File. So far, so good. Now I need some help....

I am trying to troubleshoot a module NET-AOLIM that is not working on two Windows systems. At this point my ignorance has limiited me to inserting Print lines to ID if part of a script has been executed. I have inserted Print sub routine name as first step in each sub routine. So I can at least know which subs have been called or not. I have also figured out how to print out some variables, but this is still new to me.

1. Is there a way that I can single-step through a perl script?
2. Is there a way to dump variables for reviewing values?
3. How can I deal with interactive prompts for input using TextPad?

I am currently using Capture Output=Off, Close DOS Window on Exit = OFF. This allows me to see the print lines I have inserted. But the beginning has two prompts for inputs. If I use Capture Output=On, then I am not prompted for input, and the script appears to hang.

All suggestions are welcome. Thanks for your help.

Bob
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

go to your command line interpreter.

type

perldoc perldebug >debug.txt

then open debug.txt in Textpad.

(of course this assumes that your perl\bin is in the PATH variable)
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Hello MudGuard.......
Thanks for the feedback, but had some initial problems.

1. typing perl example.pl , prompted me for inputs, output came to screen, nothing is showing up in debug.txt
2. typing perl -d example.pl went right into a debug mode, no prompts, looks like single stepping (That will solve one problem for me).
3. Tried running example.pl from texpad after redirecting to debug.txt, but still get results in command window, nothing to debut.txt

I am obviously missing something here......

Let me recap my (MIS?)understanding the sequences:

1. Open Command Window
2. type "perldoc perldebug > debug.txt
3. Open TextPAd, open debug.txt
4. Go to command window
5a. Type perl -d example.pl
OR
5b. Type perl example.pl

Is that correct?

I will have to read the perldoc perldebug text, a lot came up that I ignored initially. And also the help for perldebug. I have no problem reading the documentation, I am willing to do the work, just need to pointed in the right direction.

Quick tutorial shortcut request.....re single stepping, can I insert a breakpoint, or run until line x, and then single step? Can I then step through a few lines and again run another block of code, say the next 50 lines and single step again?

Thanks again, looking forward to this pain!
Hope this was helpful.............good luck,
Bob
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Do you see any example.pl in what I told you to do?

Just do what I suggested.
And read the file you have in Textpad then.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

This is what you asked:
Just do what I suggested.
And read the file you have in Textpad then.
And that is what I did here:
3. Tried running example.pl from texpad after redirecting to debug.txt, but still get results in command window, nothing to debut.txt
I apologize for not listing in sequence. I did as instructed but got no results. debug.txt was empty, so I thought perhaps that was going to be a file to capture results, and I would just refresh when file was modified. When that did not work, I went back to the command window to see if that is what was needed. That did not work either, with and without -d command.

I will record my current actions now:
1. Opened a command window
2. Typed perldoc perldebug>debug.txt, enter.
2a. screens of info come up, using More, pressing enter to continue.
3. Result was about 55 screens of data.
4. Opened TextPad.
5. Opened debug.txt, file is empty.
6. Checked path has perl\bin at the beginning.
7. Checked file properties of debut.txt, size=0, time and date are now.

Don't know why it is empty, but I see what you asking me to do. This is the debug documentation and you are redirecting it to a file so I can read it. I will find a way to do that, don't understand why it is not working, basic redirection.....hmmmm. I will let you know the results, stay tuned, thanks again...
Hope this was helpful.............good luck,
Bob
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I am finding that none of the perldoc commands can be redirected. Just doing perldoc -h does not get redirected. Trying this on WIN98SE and WIN98ME systems.

But it did show me that perldoc is a batch file in the bin folder. So I will try to do an autopsy on that to see if I can figure out how to redirect the output. That batch file has a lot of help info to begin with, will hopefully get me closer. :D

I just downloaded Debugger documentation from www.perl.com. Saved the html page, used TextPad Macro to Strip Tags, then did Select All and Reformated. So I now have a fairly easy to read document. Can also read the HTML version with browser. :D

Still would be nice to be able to use perldoc to get documentation on the fly, but redirection is apparently not the answer at this point. :( Hmmmm

:!: :idea: WAIT A MINUTE! TextPad to the rescue. I just made a tool that called peldoc.bat, prompts for parameter (perldebug), captures output. Now I can save the file. So I now have a generic tool for getting perldoc documentation. :D :D

Just tried it again, entering "perl" for the paramater, and now have documentation for perl overall. :D :D

Thanks for the inspiration MudGuard.

I am on the way again.....
Hope this was helpful.............good luck,
Bob
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

if perldoc can't be redirected your system is very weird.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Well, one good thing was the creation of my PerlDoc tool.

I have dumped out TOC, Perl, PerlDebug, PerlRun, PerlSyn, PerlTut, DebugTut, PerlIntro, etc...... And any new ones I need are all available at a click. I do this in a Perl Workspace. They come into TextPad results window. I save them, reformat them, resave them as Read Only, and include them in that workspace, so all the documentation I want is available every time I open up the workspace.

Have no explantation why perldoc does not redirect. Same results on WIN98SE and WIN98ME. I use redirection and piping daily for other maintentance with no trouble. Someday I will stumble across the explanation, will share it with you, and we will both say "Yeah, I knew that!"
Hope this was helpful.............good luck,
Bob
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I have made a lot of progress in my troublshooting of Perl now. But ran into a piping problem, similar to the redirection problem. Here are my results, and current questions:

I have discovered a number things that I do not yet understand, but have been able to work around:

A. In the debug mode (-d) I found that "|h" did not work. The pipe did not work with any command. I also found that the pipe used the "pager". Through the documentation I finally found that the command "o" would show me some options settings. I used command "o" but could not see the full screen of options, I was looking for something like redirection at the time. What I did see was "pager = more /e". I used "h o" and found I could change the value of pager. I changed it to "pager = more". And now the pipe worked. I could use "|o", but there was no option there for redirection. But at least the piping works now. WRONG! I closed debugger, reloaded again, and found that pager was again set to "more /e". Doing more digging through documentation, I found that the pager setting is established in C:\Perl\lib\config.pm. Not knowing how else I could make the change, I modifed that line from "more /e" to "more". Reloaded my debugger, and this is now part of my correct configuration.
Finally, my questions:
1. I don't think I should be modifying C:\Perl\lib\config.pm. How else can I make this modification for my system? Should I be making some correction in the C:\Perl\site folder instead?

2. What does the "/e" mean? What is it supposed to do? It does not appear to be a documented parameter of "more" in WIN9X systems.


B. Redirection is still not working for "perldoc perldebug > debug.txt". Perldoc is actually a batch file in C:\Perl\bin folder. But in the Windows 9x environment it only runs one line: perl -s -X %0 %1. When I single step the batch file I find that the line is entered as perl -s -X "perldoc.bat" perldebug when the batchfile parameters are filled in. If I go to command window and directly run perl -s -X "perldoc.bat" perldebug > debug.txt, then the redirection does happen. So this has something to do with the way a batch file calls itself and that impact on redirection. I suspect this may be normal behavior in WIN9X, but am confused, because it appears to work OK for MudGuard (perhaps WINNT/2K/XP ?).

I also edited the perldoc.bat file. It also had a pager definition of "more /e" which I changed to "more" for my system. Again, don't know what the "/e" is for. Hmmm, why did I bother eiditing that line, since it is not called with WIN9X? Dummy, me! :oops:

But my TextPad Tool for PerlDoc has eliminated that redirection problem anyway, and is easier to use. So thanks again for the opening to the documentation, and maybe someday we will have a real understanding of why the redirection does not work in WIN9X when a batch file calls itself as a parameter to perl.
Hope this was helpful.............good luck,
Bob
Kevin
Posts: 28
Joined: Tue Apr 01, 2003 7:55 pm

Post by Kevin »

Bob,

Try this site:

http://iis1.cps.unizar.es/Oreilly/perl/index.htm

These online books are one edition behind the printed version, but it's nice to have them available anyway. I recommend "Programming Perl", the camel book by Larry Wall, et al.

--Kevin--
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Thanks Kevin, I have been there and added to bookmarks.

Quick question?

How do I capture/dump Trace results to a file?

I can turn on tracing and set frames for different info, but cannot figure out how to dump the results to a file. Is there a predefined file/command to do this? Or what line can I add to the pl file to change the DB environments to AutoTrace=1, f=8 ? I can use TextPad to open in debug mode, but cannot set debug options so Capture Results does not give me the trace. If I don't Capture Results, I can manually set the options with the "o" command, but then I just get screens of data that I cannot seem to redirect. I have searched high and wide but cannot seem to figure out do to a trace dump. I saw a reference to a "rf file" but no info on how to call it, what it shoulc contain.

I am sure this is a simple command somewhere to solve this problem.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I have made some time to dig into "more /e", and found the following syntax for the MORE /e command that Perl had set as default for my "pager":
MORE [/E [/C] [/P] [/S] [/Tn] [+n]]< [drive:][path]filename

command-name | MORE [/E [/C] [/P] [/S] [/Tn] [+n]]

MORE /E [/C] [/P] [/S] [/Tn] [+n] [files] [drive:][path]

filename .............Specifies a file to display one screen at a time.
command-name .............Specifies a command whose output will be displayed.
/E..........Enable extended features
/C..........Clear screen before displaying page
/P..........Expand FormFeed characters
/S..........Squeeze multiple blank lines into a single line
/Tn..........Expand tabs to n spaces ('default 8')

..............Switches can be present in the MORE environment variable.

+n..........Start displaying the first file at line n

files..........List of files to be displayed. Files in the list are separated by blanks.



If extended features are enabled, the following commands are accepted at the
"-- More --" prompt:

P n..........Display next n lines
S n..........Skip next n lines
F..........Display next file
Q..........Quit
=..........Show line number
?..........Show help line
<space>..........Display next page
<ret>..........Display next line
This information is from Microsoft Knowledge Base Article - 227449, http://support.microsoft.com/?kbid=227449.

This also explains why you may find pressing ENTER at the prompt only goes one line at at a time on a WIN2K system, because /E is set.

According to this article these switches are only liste for Windows 2000 Server and 2000 Professional. (I can confirm they do not work on WIN98SE/ME. I cannot confirm right now for XP/NT).

Does this mean that the Perl installation on my system made an error? Shouldn't it have been modified correctly when it identified my system as WIN98SE/ME? If the parameter for "pager" was set wrong, what other errors might I expect to see?
Hope this was helpful.............good luck,
Bob
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

The real question is why are you still using W98? I used to like it myself, much. I had it set up to be very stable and virtually never had a crash (that means I did have crashes), but if you do much complex work or use multiple programs at the same time you are going to run out of memory quickly.

I reluctantly switched to W2K, but havn't looked back and would not go back. Never a thought about memory problems and no crashes whatever. And this has nothing to do with the way the innerds work...and W2K does not suffer from Activationitis.
Best Wishes!
Mike Olds
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Hi Mike:
The real question is why are you still using W98?

I have multiple systems and environments. My work must be done in same environment as my clients. I don't always have a choice. And over 70% of my accounts are still using WIN9X.

Nope. The real question now still is:
How can I do a dump of Perl debugging steps? :?:

Secondary question is since this parameter was not correct for this environment, what others are wrong also? :?:

Since I am self-teaching, it was not obvious why "|h" was an invalid command. All documentation said that was normal. I won't confess how many hours it took for me to locate the cause and the solution. The only advantage is that it has caused me to get "under the hood" sooner and deeper than I had planned at this point. I really want to spend my time right now on making an "established" module work for this project. I really did not want to debug a good program by another author in a language I am not familiar in.

Not complaining, actually looking forward to another tool in my toolbox.
:D
Hope this was helpful.............good luck,
Bob
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

OK Bob, I understand, now the question is why work with Perl in that environment. It was not written for it, and the Windows port is still very young, and without the ability to write web scripts you are missing half the fun. At the most I would do what I am doing on windows with it which is use it via CYGWIN where it is at least in its native environment, and where you can set up an internal web server...the best of three worlds.

If you have customers that need what you develop in Perl then you could install CYGWIN on their computers.
Best Wishes!
Mike Olds
Post Reply