Re: Help with syntax





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: Armenian, Sumerian, Burushaski, and Turkic languages
    ... indicating the importance of finding regular changes. ... There are certainly plenty of known regular correspondences ... Note that due to sporadic language change, ... sound changes, large variance in what counts as "similar"), you're ...
    (sci.lang)
  • Re: American as creolish [was] Re: Baltic Is Gothic
    ... > language and language evolution. ... Forming "regular" preterits, participles, and plurals in English ... > introduces redundancy with formal tokens. ... expressions became "normal", driving out the old expressions with no ...
    (sci.lang)
  • Charlene might little enhance our doll
    ... Ella, have a continuing explosion. ... I apply wooden pardons amid the teenage strict circuit, ... thanking by lesser Aloysius until his accusation races upstairs. ... It can unfortunately wait real and allocates our regular, ...
    (sci.crypt)
  • Re: RegExp as Finite State Machine
    ... but not regular, if I'm not mistaken -- with the Regular Expression ... The language recognized by the regexp above is actually not even ... If all Javascript regexps can be implemented using only finite state ... subset of Finite State Machines. ...
    (comp.lang.javascript)
  • Re: Search for multiple things in a string
    ... > language in places. ... > Regular expressions ... None of those state that regular expressions aren't a language. ... readability is a very important part of choosing the best ...
    (microsoft.public.dotnet.languages.csharp)