Perl Script to read an excel file into an array and search in the UNIX directories

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Perl Script to read an excel file into an array and search in the UNIX directories
# 1  
Old 12-22-2011
Question Perl Script to read an excel file into an array and search in the UNIX directories

Hi,
I want the Perl script with versions 5.8.2 and 5.8.5 starting with

#!/usr/bin/perl

The Perl program should read the excel file or text file line by line and taking into an array and search in the UNIX directories for reference file of .jsp or .js or .xsl with path .The Object names in the excel or text file will be having the spaces
(for Ex:
Eliminate Proc
Sample Text
----------
--------
)

The output will be like this:
line1
.../start/login.jsp
../start/reg.js
--------------------------
line2
../start/login.xsl
../script/log.js
----------------

.....



Plz help me out in this ..........................
Thanks in advanceSmilie
# 2  
Old 12-22-2011
what u tried so far ?
# 3  
Old 12-22-2011
Error

Code:
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
# usage $0 <directory list>
open (my $input, '<', "names.txt")
||die "Couldn't open names.txt file:\n\t$!\n";
while (<$input>){
print "$_\n";
find(sub {wanted($_)} , @ARGV);
}

sub wanted{
if (/\.jsp?$/){
my $regex=shift;
open(my $current_file, '<', $_) || print "Could not read $_:\n\t$!\n";
FILE:
while(<$current_file>){
if(/$regex/){
print "$File::Find::name";
next FILE;
}
}
close($current_file);
}
}


So, Plz correct me and after searching I want to get the Output in output file (either text file or excel file )with Object name and reference file .........

Thanks .

Last edited by pasam; 12-22-2011 at 06:20 AM.. Reason: wrong format
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script to Merge contents of 2 different excel files in a single excel file

All, I have an excel sheet Excel1.xls that has some entries. I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls These may be in different workbooks. They are totally independent made by 2 different users. I have placed them in a... (1 Reply)
Discussion started by: Anamika08
1 Replies

2. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

3. Shell Programming and Scripting

Perl :Is it possible to read the excel 2007 sheet on unix machine using spredsheet::xlsx module

I have an Excel 2007 excel sheet on windows machine and using Spreadsheet::XLSX I had written a script to read the excel sheet and was successful. My requirement is I need to generate another excel sheet from the old excel 2007 sheet on unix machine. Now is it possible to read the excel... (2 Replies)
Discussion started by: giridhar276
2 Replies

4. Shell Programming and Scripting

perl- read search and replace string from the file

Dear all, I have a number of files and each file has two sections separated by a blank line. At the top section, I have lines which describes the values of the alphabetical characters, # s #; 0.123 # p #; 12.3 # d #; -2.33 # f #; 5.68 <blank line> sssssss spfdffff sdfffffff Now I... (4 Replies)
Discussion started by: sasharma
4 Replies

5. Shell Programming and Scripting

perl: Read array from a flat file

Hello Guru's I want to read an array into a flatfile Please let me know how to do the same So far this the below code use strict; use warnings; open (my $data , '<', $ARGV)|| die "could not open $ARGV:\n$!"; my @array=(<$data>); my @sorted=sort... (8 Replies)
Discussion started by: Pratik4891
8 Replies

6. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

7. UNIX for Dummies Questions & Answers

Read excel file using shell script

Is it possible to read an excel sheet using shell script ? (2 Replies)
Discussion started by: hiten.r.chauhan
2 Replies

8. Shell Programming and Scripting

Perl script to sort an Excel file

Hello! I need to sort a file that is partly in English partly in Bulgarian. The original file is an Excel file but I converted it to a tab-delimited text file. The encoding of the tab delimited file is UTF-8. To sort the text, the script should test every line of the text file to see if... (9 Replies)
Discussion started by: degoor
9 Replies

9. Shell Programming and Scripting

Perl: Read directories and assign to array

I would like to read directories and assign to an array where the user can select a directory from the output. For example, a dir list will populate with a number assigned to each dir. I would like to ask the user to select the dir they want. TIA, I don't know what this would be called so I... (2 Replies)
Discussion started by: man
2 Replies

10. Shell Programming and Scripting

Read Ms-excel file in unix

Hi, I have the Ms Excel file(test.xls) in my UNIX box. I would like to read the excel file and create files for each column. Please find an example. My excel file like this data: Num Data 1 a1 2 b2 3 c3 4 d4 5 e5 6 f6 7 h7 My output: I want create 2 files(num.log and... (3 Replies)
Discussion started by: koti_rama
3 Replies
Login or Register to Ask a Question