Guess I should have given all of the code from the
start...sorry...here is all of it:
#!/usr/bin/perl
opendir (CURRDIR, '') || die "Can't open it!";
@file_list = join ("\n", readdir (CURRDIR)) . "\n";
$i = 1;
foreach $file_name ( @file_list ) {
print "$i - " . "$file_name";
$i ++;
}
closedir CURRDIR;
I think I already see what you mean...by joining the directory names
with newlines I made them into one string...AHA!!
So, a new question...what's a better way to do what I am trying to do?
Thanks,
CTP
At 12:42 PM -0500 3/9/01, Chris Nandor wrote:
>At 09:36 -0800 2001.03.09, Christopher Palmer wrote:
>>In the following code:
>>
>>foreach $file_name ( @file_list ) {
>>print "$i - " . "$file_name";
>>$i ++;
>>}
>>
>>why is the output
>>
>>1 - filenameA
>>filenameB
>>filenameC
>>
>>instead of
>>
>>1 - filenameA
>>2 - filenameB
>>3 - filenameC
>
>Because @file_list = "filenameA\nfilenameB\nfilenameC\n" instead of
>("filenameA\n", "filenameB\n", "filenameC\n"). It is all one string,
>instead of three strings. Perhaps you could show us how you create
>@file_list.
>
>--
>Chris Nandor [EMAIL PROTECTED] http://pudge.net/
>Open Source Development Network [EMAIL PROTECTED] http://osdn.com/