in reply to Handling uninitialized values
Yet Another Way Of Doing It
I would rather have the slashes not be part of the dirs or subdirs. Instead, consider that the full path merely consists of $dir, $sub_dir and $file, join'ed together with slashes. Then, grep should remove empty/undefined entries:
my $dir = '/tmp' my $sub_dir; my $file = 'foo.txt' my $path = join('/', grep { defined && $_ ne '' } ($dir, $sub_dir, $fi +le)); print "$path\n";
--bwana147
|
|---|