perl code to search existing files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl code to search existing files
# 1  
Old 04-17-2012
perl code to search existing files

Hi,
I have a string like:

read_lib {$lib/a.lib $lib/b.lib $lib/c.lib ..... }

Now, I want to search existence of all these *.lib files in $lib directory.
Please suggest- how to do it.

Thanks
-rkg
# 2  
Old 04-25-2012
Use "if" with "-e" to check to file existence:

Code:
if (-e $your_file) {
# commands to execute
}

# 3  
Old 04-26-2012
Thanks Thomas!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - Append data to existing excel cell

Hello All, I have the following code in PERL to write data to excel sheet. Can someone please help me about how to append data to an exisitng cell? For ex in the below given case,Cell 1,1 has Active State PERL Now I want to add a new line like "prorgamming" without overwritting the... (3 Replies)
Discussion started by: prasperl
3 Replies

2. Shell Programming and Scripting

perl: search replace in multiple files

When I use special characters the command to replace multiple files with a string pattern does nt work. ---------- Post updated at 12:33 PM ---------- Previous update was at 11:38 AM ---------- This works perl -pi -e 's/100/test/g' * This does nt work perl -pi -e 's... (1 Reply)
Discussion started by: w020637
1 Replies

3. Shell Programming and Scripting

Search Files from Array and link to original location in Perl

Hello, Question is related to Perl: I need to search few of the files from the array of file names. And after grepping the file names from an array I need to link these files to original location. The original location in this case is ref_path as input from the user. ##$ref_path is... (3 Replies)
Discussion started by: aarora1
3 Replies

4. Shell Programming and Scripting

How to delete already existing data in a file using perl? Pls help me!!

Dear Friends, I need urgent help from u.. I have two files,file1 & file 2.. file1 have a existing data of file2.So i want to delete those existing datas from file1 (which contain the data from file1) My file1 like this rs39348 1 1045729 A G 0.1791 0.2054 0.84 ... (3 Replies)
Discussion started by: sureshraj
3 Replies

5. Shell Programming and Scripting

modify Existing MS excel workbook in perl

Hi I need to modify an excel file in perl and for which I installed perl in Linux 1. Open a existing excel file 2. delete an unwanted Sheet called "summary" 3. and i want to insert some data into range of cells ( B1:B11) 4. Remove unwanted value called "Sum" repeated in the... (1 Reply)
Discussion started by: luke_devon
1 Replies

6. Shell Programming and Scripting

Code help with search script perl

Hello, I have a script, but its sorta broke and I need help to tweak it #!/usr/bin/perl my @files_to_search = ("exportOBJ-sark.txt","ResourceRecText-ALL.txt","exportdnsrr-report.txt"); open (FL, "sark.com.txt"); my %search_hash = (); while (my $line = <FL>) { my @parts =... (12 Replies)
Discussion started by: richsark
12 Replies

7. Shell Programming and Scripting

copy substr in existing string in Perl

Any clue to write something to a particular location in Perl? Suppose $line = ‘abc cde 1234” How to write ( example string "test") on location 4 without parsing the whole line. Output should be $line = ‘abctest 1234” this is not search and replace. just to add substring into... (3 Replies)
Discussion started by: jaivipin
3 Replies

8. Shell Programming and Scripting

Indexing or Filtering code- Pattern Search by comparing two files

So here is goes to the Gurus of shell programming......I have tried a lot of different ways and its a very challenging code to write but i am enjoying it as i troubleshoot and hopefully someone can provide me a better option....Thank you in advance for your time and support....Much appreciated... ... (12 Replies)
Discussion started by: aavam
12 Replies

9. Shell Programming and Scripting

search file, change existing value based on input (awk help)

I have a file (status.file) of the form: valueA 3450 valueB -20 valueC -340 valueD 48 I am tailing a data.file, and need to search and modify a value in status.file...the tail is: tail -f data.file | awk '{ print $3, ($NF - $(NF-1)) }' which will produce lines that look like this: ... (3 Replies)
Discussion started by: nortonloaf
3 Replies

10. Shell Programming and Scripting

Perl code to search for filenames that contain special characters

Hello, I have a requirement to search a directory, which contains any number of other directories for file names that contain special characters. directory structure DIR__ |__>DIR1 |__>DIR2__ |__>DIR2.1 |__>DIR2.2 |__>DIR3 .. ... (8 Replies)
Discussion started by: jerardfjay
8 Replies
Login or Register to Ask a Question