Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl line by line debug

Status
Not open for further replies.

sriramus

Technical User
Nov 11, 2005
8
GB
Hi All,

can i debug perl line by line as i do in c with F8. i run a perl program which contains a print statement, i dont get any errors and it runs smoothly returning my prompt signifying that there were no errors but i dont see any output on the cmd window.

Below is the perl script which i ran

#!perl -w

use strict;
use File::Find;

my %directories;
find( \&filehandler, "D:/" );

for my $filename ( sort keys %directories ) {
my @dirlist = @{$directories{ $filename } };
if ( scalar @dirlist > 1 ) {
print "$filename\n";
for ( @dirlist ) {
print " $_\n";
}
} # if
} # for

sub filehandler {
# Check to make sure that it's a file, not a directory
return unless -f $File::Find::name;

# Just take the filename, and convert to lowercase
my $nameonly = lc $_;

# See if it's a DLL or EXE file
return unless $nameonly =~ m/\.(dll|exe)$/i;

$directories{ $nameonly } = [] unless defined $directories{ $nameonly };
push( @{$directories{ $nameonly } }, $File::Find::dir );
}

I encounter this even with other scripts, can any one tell me why this happens.

Thanks in advance.
 
You can use the perl debugger by using the -d switch:
Code:
perl -d script.pl [args]
You'll probably want to take a look at perldoc perldebug for more info.

Also, regarding the lack of output, this line looks a bit suspect to me.
Code:
if ( scalar @dirlist [b][red]>[/red][/b] 1 ) {
Maybe that should read
Code:
if ( scalar @dirlist [b][blue]>=[/blue][/b] 1 ) {
unless you're looking for duplicates. In which case, '>' would be the way to go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top