Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top