I have a script that loops through a directory and it's sub-dir's. To get the files in the directory root I either make the sub-dir undefined or a null string. My question is a style and usage issue as "-w" complains if it's undefined. Is there a better way to do this sort of thing? Here's a quick test script of what I'm talking about:
#!/usr/local/bin/perl -w
use strict;
my $dir = '/tmp/';
my $sub_dir;
my $file = 'foo.txt';
my $path = "${dir}${sub_dir}${file}";
print "$path\n";
This causes the "Use of uninitialized value in concatenation" error. But if you set
$sub_dir = ""; it halts the warnings. Just looked kind of odd/ugly, thus why you are reading this now.
-THRAK
www.polarlava.com