Equivalent of ls -d

A

Another Brian

I'm trying to get a list of the files and directories. I was using:
my @FILES = `ls -ld $INPUT`;

Where the value being passed into $INPUT includes a wild card that
identifies lots of files and directories. I am getting this error:
ksh: /acct/v/vobadm/bin/stattest.pl: 0403-027 The parameter list is
too long.

I do not want to descend into subdirectories. I tried using readdir
but if $INPUT contains a wild card, it lists the files in the
subdirectories.

Is there a Perl equivalent of "ls -d $INPUT"?

Thank you,
Brian
 
A

A. Sinan Unur

I'm trying to get a list of the files and directories. I was using:
my @FILES = `ls -ld $INPUT`;

Where the value being passed into $INPUT includes a wild card that
identifies lots of files and directories. I am getting this error:
ksh: /acct/v/vobadm/bin/stattest.pl: 0403-027 The parameter list is
too long.

I do not want to descend into subdirectories. I tried using readdir
but if $INPUT contains a wild card, it lists the files in the
subdirectories.

Huh?

Could you please share with us the code that does that?

Sinan
 
X

xhoster

Another Brian said:
I'm trying to get a list of the files and directories. I was using:
my @FILES = `ls -ld $INPUT`;

Where the value being passed into $INPUT includes a wild card that
identifies lots of files and directories. I am getting this error:
ksh: /acct/v/vobadm/bin/stattest.pl: 0403-027 The parameter list is
too long.

Yep, that is a shell limitation.
I do not want to descend into subdirectories. I tried using readdir
but if $INPUT contains a wild card, it lists the files in the
subdirectories.

I find that hard to believe. Can you demonstrate this?
Is there a Perl equivalent of "ls -d $INPUT"?

On a modern perl, its standard glob can deal with much larger file lists
than the shell can. It naturally does the equivalent ls's -d. To simulate
ls's -l you would need to stat each file coming out of glob.

Xho
 
J

Juha Laiho

Another Brian said:
I'm trying to get a list of the files and directories. I was using:
my @FILES = `ls -ld $INPUT`; ....
I do not want to descend into subdirectories. I tried using readdir
but if $INPUT contains a wild card, it lists the files in the
subdirectories.

You can check the entries returned from readdir -- see
perldoc -f -X

.... f.ex.

$ent = readdir( DIR );
if (-f $ent) {
// do something for plain files
}
 
A

Another Brian

Yep, that is a shell limitation.


I find that hard to believe. Can you demonstrate this?
Unfortunately I've deleted the test code and haven't been able to
quickly recreate it.
On a modern perl, its standard glob can deal with much larger file
lists
than the shell can. It naturally does the equivalent ls's -d. To
simulate
ls's -l you would need to stat each file coming out of glob.
GLOB! That's the command. I was just too brain dead to remember it.
Thank you. It works great!

Brian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top