The following is the script:
-----------snip------------------------
#!/usr/bin/perl -w
use strict;
use File::Basename;
my @lines = dirname `dir /b/s`; print "@lines\n";
-----------snip------------------------
The following is the input:
C:\Perl\scripts\shots\sp2\shot_1\dir.txt
C:\Perl\scripts\shots\sp2\shot_1\filename.0001.cin
C:\Perl\scripts\shots\sp2\shot_1\filename.0002.cin
C:\Perl\scripts\shots\sp2\shot_1\filename.0003.cin
C:\Perl\scripts\shots\sp2\shot_1\filename.0004.cin
C:\Perl\scripts\shots\sp2\shot_1\filename.0005.cin
C:\Perl\scripts\shots\sp2\shot_1\file_name.0001.cin
C:\Perl\scripts\shots\sp2\shot_1\file_name.0002.cin
C:\Perl\scripts\shots\sp2\shot_1\file_name.0003.cin
C:\Perl\scripts\shots\sp2\shot_1\file_name.0004.cin
C:\Perl\scripts\shots\sp2\shot_1\file_name.0005.cin
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0001.rgb
C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0002.rgb
C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0003.rgb
C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0004.rgb
C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0005.rgb
I would like the output to be the following:
C:\Perl\scripts\shots\sp2\shot_1 <--current
directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory <--sub
directory
'dirname' seems to only pick up the following:
C:\Perl\scripts\shots\sp2\shot_1
I also tried the following code:
-----------snip------------------------
#!/usr/bin/perl -w
use strict;
use File::Basename;
my @dir_contents = `dir /b/s`;
for (@dir_contents) {
my @paths = dirname $_;
print "@paths\n";
-----------snip------------------------
But, I get the following (truncated for our purposes):
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
C:\Perl\scripts\shots\sp2\shot_1\sub_directory
I've also tried a number of other things to no avail.
Does anyone have a solution to my delima?
I've also tried the following code, but, it too fills
the buffer.
#!/usr/bin/perl -w
use strict;
my (@lines, $line, @paths);
@lines = `dir /b/s`; print @lines;
for (@lines) {
if (/\w+\.\d+(\.\w+)$/) {
$line = $`;
$line =~ s/$/\n/;
push @paths, $line;
print "@paths";
}
}
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>