Have Perl echo code while executing it w/o prompting me per line
am 21.07.2009 00:30:51 von Sara Kinner
--0016e642d154c4f84c046f2ab064
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
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.
--0016e642d154c4f84c046f2ab064--
Re: Have Perl echo code while executing it w/o prompting me per line
am 21.07.2009 04:58:09 von chas.owens
On Mon, Jul 20, 2009 at 18:30, Sara Kinner 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-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/