funky_aunt has asked for the wisdom of the Perl Monks concerning the following question:

I just downloaded active perl from activestate for windows xp when I write my scripts they just flash too fast for me to read. Like they need a C++ type getch(); command. Is the window closing on exit? If so, How do I stop this from happening? Thanks, Tracy

Replies are listed 'Best First'.
(Ovid) Re: flashing perl
by Ovid (Cardinal) on Feb 09, 2002 at 01:23 UTC

    This is a pretty common problem when you are first starting. The *best* way to deal with this to open up a DOS prompt and cd \path\to\script. Then, you can run the script from the command line and the window won't close.

    You could use something like getch() to make the window pause before closing, but it's an ugly hack (IMHO). Working from the command line is cleaner.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      Or you could open a DOS prompt, cd into the dir of your script, and do:

      perl script.pl > output.txt

      Then you could just take a look at output.txt @:)

      ----------------------------------
      away: Constructing a sound defense

Re: flashing perl
by Chady (Priest) on Feb 09, 2002 at 08:37 UTC

    I tend to throw in a <>; at the end of my script, this will require an Enter keypress at the end to close the window.


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
Re: flashing perl
by TStanley (Canon) on Feb 09, 2002 at 01:29 UTC
    You need to simply open the MS-DOS command prompt, and run the program from there. For example, if I had a program located in C:\MyPerlScripts, I would type the following at the prompt:
    C:\>cd MyPerlScripts C:\MyPerlScripts>perl script.pl
    Any output of the program would go to STDOUT. I am assuming that you are merely clicking on the icon for the program, which would run it, but any output would simply display quickly, then disappear when the program exits, as the command shell created when the program runs, would exit.

    TStanley
    --------
    "Suppose you were an idiot... And suppose you were a
    member of Congress... But I repeat myself." -- Mark Twain

Re: flashing perl
by braughing (Sexton) on Feb 09, 2002 at 03:12 UTC
    You can download a text editor that will call perl to run your program for you, and will then capture its output and display it alongside. This is comforting if you're used to having an IDE to work with. I'm new to perl, and I'm using UltraEdit, which I found on the outside links page on this site. (Update: I messed up the link, but now it works. b] (Update: thanks to Yves/DeMerphq for his improved UltraEdit Wordfile.)
Re: flashing perl
by gav^ (Curate) on Feb 09, 2002 at 02:58 UTC
    You can always sneak in a system("pause") which I find handy sometimes...

    gav^

Re: flashing perl
by beebware (Pilgrim) on Feb 09, 2002 at 13:22 UTC
    There are a number of options:
    • Launch a 'console' (MS-DOS window) by going to Start->Run and typing in either command.com or cmd (dependent on your Windows version). Then just type
      cd /path/to/perl/script
      perl scriptname.pl and it'll execute in the window.
    • Get an application such as Editplus or Ultraedit allow you to run Perl scripts in a window.
    • Add <>; at the end of your script. You'll then have to press Enter to exit out of it