in reply to Putting all the files in an array

As you said "unique header files in cwd" I suppose you mean recursively, starting from the cwd (as filenames are always unique per directory).

use File::Find; my @headers; my %seen; find(sub { push @headers, $_ if -f && /\.h$/ && !$seen{$_}++; }, ".");

Replies are listed 'Best First'.
Re^2: Putting all the files in an array
by Anonymous Monk on Mar 20, 2011 at 12:31 UTC

    Hi eliya - if I want to get all the file extensions instead of just .h's,how can I change the above code to achieve that?

      Changing a program is usually done using a text editor, and the process is commonly called "programming".

      You will have to employ both, and some understanding of what actually happens in the program. I suggest you read File::Find and perlop to understand the program you have, and then come back if you have specific questions as to how a particular construct in the program works, or what change you made and why it behaves the way it does.