On Mon, Jul 20, 2009 at 18:30, Sara Kinner<sara.kin...@gmail.com> wrote:
> How can I make Perl echo each line of code before executing it? I
> don't want to hit return after each code line is printed: I just want
> Perl to print it as it's executing code normally.
>

Take a look at [Devel::Trace][0].  Once you have installed it, you can say

perl -D:Trace program.pl

and it will print out the lines of code that are executing.

Given this code:

#!/usr/bin/perl

use strict;
use warnings;

my $s = "Hello";

if ($s eq "Hello") {
        $s .= " World";
} else {
        print "this doesn't execute\n";
}

print "$s\n";

You get the following trace:

>> c.pl:6: my $s = "Hello";
>> c.pl:8: if ($s eq "Hello") {
>> c.pl:9:      $s .= " World";
>> c.pl:14: print "$s\n";
Hello World

[0] : http://search.cpan.org/dist/Devel-Trace/Trace.pm

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to