Help me write a Perl script to remove the names of directories which have no files

Status
Not open for further replies.

hseong3

Newbie level 1
Joined
Feb 19, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,293
I have a text (list.txt) to process which looks like this:

.\hlee4\unix
.\hlee4\perl
file1.pl
file2.pl
file3.pl
.\hlee4\linux
file_a.txt
file_b.txt
.\hlee4\C++
.\hlee4\Verilog
file_x.v
file_y.v

The text file consists of the names of directories and the files in each directories. If the directory is empty, no files will be listed under it.

I have been trying to write a Perl script to remove the names of directories which has no files in it. I really have no idea how to do this.

The processed text should look like this:

.\hlee4\perl
file1.pl
file2.pl
file3.pl
.\hlee4\linux
file_a.txt
file_b.txt
.\hlee4\Verilog
file_x.v
file_y.v

with .\hlee4\unix and .\hlee4\C++ removed.

I have been looking at this for a few days now. HELP !!
 

Re: Perl - remove lines

Hi please try the script that I have attached.

The sorce file is given as command line input. The output after removing lines will be entered into "updated.txt"
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…