in reply to I want specific word to be stored in a CSV file
In Perl, the grep function takes an array or a list of items, applies the piece of code supplied as a first argument, and returns the items for which this piece of code evaluates to true.@files = grep("EXP", readdir(DIR));
If you are looking for "EXP" in the file names, then you could try to change it to:
which would give you an array of file names matching the /EXP/ pattern.my @files = grep { /EXP/ } readdir(DIR);
The second error in your code is that the readdir operator returns a list of files without the path, so that you need to prefix the file names with the $directory variable to be able to open them. Using the glob function might be easier and provide the file list, with the path, in a single step, for example you might try something like this:
You haven't said enough for me to be able to provide more guidance at this point.my @files = glob ("/home/grds/datafile/*EXP*.*");
Update: fixed a typo.
|
|---|