I've been working on some code to rename MP3 tags. I wrote the following to test out some functions. I wanted to sort out files that began with numbers. I now know about the != and the "ne" (string based) but wonder why this is working.
# PRINTS SECOND LINE IF FILE NAME BEGINS WITH A NUMBER
SAMPLE CODE
#------------------------------
use File::Find;
{
# the base directory where the files are change to a local directory
my $baseDir = "//users//yourName//desktop//MP3s";
my $fileName; # the complete filename with directory prepended
my @fileList; # array to hold the names of the files in the directoy
my $len; # used for array bounds
my $i = -1; #loop counter
find(\&listItNow, $baseDir);
sub listItNow{
print "this is the name-->$_\n";
if ($_ != "-d") { # THIS IS THE BAD PART
### THIS BRANCH TAKEN WITH ANY FILE NAME THAT
###
### STARTS WITH A NUMBER
$i += 1;
$fileList[$i] = $_;
print "BRANCH-$fileList[$i] $i\n";
}
return}
}
#----------------------
#----------------------
What happens is any file that begins with a number, takes the branch. All others do not.
# PRINTS SECOND LINE IF FILE NAME BEGINS WITH A NUMBER
SAMPLE CODE
#------------------------------
use File::Find;
{
# the base directory where the files are change to a local directory
my $baseDir = "//users//yourName//desktop//MP3s";
my $fileName; # the complete filename with directory prepended
my @fileList; # array to hold the names of the files in the directoy
my $len; # used for array bounds
my $i = -1; #loop counter
find(\&listItNow, $baseDir);
sub listItNow{
print "this is the name-->$_\n";
if ($_ != "-d") { # THIS IS THE BAD PART
### THIS BRANCH TAKEN WITH ANY FILE NAME THAT
###
### STARTS WITH A NUMBER
$i += 1;
$fileList[$i] = $_;
print "BRANCH-$fileList[$i] $i\n";
}
return}
}
#----------------------
#----------------------
What happens is any file that begins with a number, takes the branch. All others do not.