Re: Help with syntax



Wow. Thanks a lot. I can't believe I posted a semicolon question to
the newsgroup. I should remember that line number error don't always
refer to the exact line where the error is.


Thanks again.


On Jan 29, 4:20 pm, "kens" <kenslate...@xxxxxxxxxxx> wrote:
On Jan 29, 6:35 pm, "kramer31" <kramer.newsrea...@xxxxxxxxx> wrote:



Hi. I used perl a few years ago and found it to be wonderfully
powerful, but I don't have my old code (it's proprietary) and I seem
to have forgotten some of the subtelties of the language including how
to use references properly ... I'm using strict here to help catch
some of these subtle errors at compile time.

Anyway, can someone look at the code and tell me what the *bleep* I'm
doing wrong here?

#!/usr/bin/perl -w
use strict;

sub checkDir {
my $curDir = $_[0];
my %files = %{$_[1]};
my $file;

chdir($curDir);

my @directories;
my @listing=`ls`;
my $fileType;
my $myDir = `pwd`;

foreach $file (@listing) {
print "list: $file";
$fileType=`file $file`;
if($fileType =~ /directory/) {
print "Added to directory\n";
push @directories, $file;
}
else {
if($fileType !~ /symbolic/) {
print "regular file\n"
if(! exists $files{ $file }) { #b
my @tmpArray;
$files{ $file } = \@tmpArray;
}

push @{ $files{ $file } }, $myDir; #a

}
}
}

}my $curDir = `pwd`;
my %files = ();

checkDir($curDir, \%files);

#end of code

The error at line labeled # a is:
"my" variable %files masks earlier declaration in same scope

The error at line labeled #b is:
syntax error

Any help would be much appreciated.Put a semicolon at the end of this line:
print "regular file\n"

HTH, Ken

.



Relevant Pages

  • Re: copying field values
    ... evangelism: XHTML 1.0 Strict ... First I post when I want because if I make errors this newsgroup can ... One more thanx for your help josh:) ...
    (comp.lang.javascript)
  • Re: getting remote image sizes with image::size lwp
    ... messages, the clearly marked lines they refer to, and a description of what happens or doesn't when you ... use strict; ... use warnings; ... at the top of your script. ...
    (perl.beginners)
  • Re: STRICT in VB
    ... Strict is only available in .net, and it is available in vb.net. ... have posted your .net question to a VB 'classic' newsgroup. ... (a recent experience with VB.Net suggests that implicit type conversion is ...
    (microsoft.public.vb.general.discussion)
  • Re: putting an image link into the CSS
    ... element has to refer to a graphic providing information about the purpose ... evangelism: XHTML 1.0 Strict ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: English usage
    ... Programmers are supposed to be amongst the brightest people on the planet. ... Agreed, but it also wouldn't hurt for writers to this newsgroup to read the group for a while before posting, and learn how to use the word 'question'. ... I believe you're much too strict. ... Americans and Australians can use English somewhat differently than Britains but just as correctly. ...
    (comp.lang.c)