T
Ted
I have appended a simple test script.
The context is this. There is a directory in which all of the files
have been created with file names consisting of a root, a six digit
date, and a 3 character extension, all separated by a period. I
expected the call to split would give me the three components of the
file name. It doesn't. When I run this scriplet, I find
$file_root,$bad_date, and $fext remain empty and the print statement in
the conditional block gives me the original file name rather than the
root concatenated with the extension (i.e. the result should be, but
isn't, the original file name with the six digit date removed).
Any ideas as to what I missed?
Ted
===============================================
$some_dir = "C:/FVA/data/univeris/univeris0608";
opendir (DIR, $some_dir) || die "can't opendir $some_dir\n";
@fnames = readdir(DIR);
closedir DIR;
$count = @fnames;
print $count;print "\n";
$c = 0;
my %file_names;
for ( $i = 0 ; $i < $count ; ++$i ) {
++$c;
print "$fnames[$i]\n";
($file_root,$bad_date,$fext) = split(/./,$fnames[$i]);
print "file root = $file_root\nbad date = $bad_date\nfile extention =
$fext\n";
if ( length($file_root) > 0) {
$file_names{$fnames[$i]} = "$file_root.$fext";
print $file_names{$fnames[$i]};print "\n\n";
}
}
print "\nThere are $c files in $some_dir.\n";
The context is this. There is a directory in which all of the files
have been created with file names consisting of a root, a six digit
date, and a 3 character extension, all separated by a period. I
expected the call to split would give me the three components of the
file name. It doesn't. When I run this scriplet, I find
$file_root,$bad_date, and $fext remain empty and the print statement in
the conditional block gives me the original file name rather than the
root concatenated with the extension (i.e. the result should be, but
isn't, the original file name with the six digit date removed).
Any ideas as to what I missed?
Ted
===============================================
$some_dir = "C:/FVA/data/univeris/univeris0608";
opendir (DIR, $some_dir) || die "can't opendir $some_dir\n";
@fnames = readdir(DIR);
closedir DIR;
$count = @fnames;
print $count;print "\n";
$c = 0;
my %file_names;
for ( $i = 0 ; $i < $count ; ++$i ) {
++$c;
print "$fnames[$i]\n";
($file_root,$bad_date,$fext) = split(/./,$fnames[$i]);
print "file root = $file_root\nbad date = $bad_date\nfile extention =
$fext\n";
if ( length($file_root) > 0) {
$file_names{$fnames[$i]} = "$file_root.$fext";
print $file_names{$fnames[$i]};print "\n\n";
}
}
print "\nThere are $c files in $some_dir.\n";