473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Reading files from the parent directory

Hi,
I have to read files from the parent directory and delete those files. This parent directory contains logs files. This directory also contains some sub directories and I do not want to delete files from these sub directories. I am using this code
opendir(DIR, $lpath);
@flist = readdir(DIR);
closedir(DIR);
when I do this @flist also contains files from sub directories and I do want that.
How can I avoid reading files from the sub directories. Any help is appriciated.

-Supra91
Aug 2 '07 #1
2 3826
numberwhun
3,509 Expert Mod 2GB
Hi,
I have to read files from the parent directory and delete those files. This parent directory contains logs files. This directory also contains some sub directories and I do not want to delete files from these sub directories. I am using this code
opendir(DIR, $lpath);
@flist = readdir(DIR);
closedir(DIR);
when I do this @flist also contains files from sub directories and I do want that.
How can I avoid reading files from the sub directories. Any help is appriciated.

-Supra91
First, whenever you post ANY code to the forum, please be sure and place it withing the appropriate code tags as described on the right in the editor window.

Instead of trying to "open" the directory, why not just use the File::Util module from CPAN? It will probably do what you want to do, just read the help page.

Regards,

Jeff
Aug 2 '07 #2
KevinADC
4,059 Expert 2GB
Hi,
I have to read files from the parent directory and delete those files. This parent directory contains logs files. This directory also contains some sub directories and I do not want to delete files from these sub directories. I am using this code
opendir(DIR, $lpath);
@flist = readdir(DIR);
closedir(DIR);
when I do this @flist also contains files from sub directories and I do want that.
How can I avoid reading files from the sub directories. Any help is appriciated.

-Supra91
You are mistaken. That will read only the file names and folder names in the directory you open. It will not open any sub directories and read the names of anything in them. If you are getting files/folders of sub directories included in the output then you are doing something different than what you posted.

Kevin
Aug 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
2
by: MDW | last post by:
I’ve got a menu file that’s saved as an .shtml document. I don’t want to post the code, but essentially it’s a simple HTML table, with an XSL template wrapped around it. This way, I can...
1
by: Michael Palmer | last post by:
I'm reading xml from SQL Server 2K with VB.net using an XSD schema file and SQLXML 3.0. I have the below code working fine, but I'd like to change the code from reading the schema file from a...
3
by: Nick | last post by:
Is it possible to read a list of files from a specified directory using VB.net We have company intranet and I have created a page that displays photos from different events. I have coded a page...
10
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in...
2
by: Alan Bak | last post by:
HI I am running Active Perl on a Windows XP machine. I am hoping to get some advise on a strategy to monitor and copy files that are arriving in a directory and need to be copied to a second...
4
by: davin.pearson | last post by:
Here is my file index.php: <?php include "../parent.php"; ?> When I try to run this code on a Linux server, it gives me the following error message: Warning: main(): open_basedir...
4
by: Laharl | last post by:
My Operating Systems professor has assigned homework that basically boils down to implementing ls -lra, but with a different output format. In other words, list the files and subdirectories (and a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.