12-22-2011
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
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
Is it possible to read an excel sheet using shell script ? (2 Replies)
Discussion started by: hiten.r.chauhan
2 Replies
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
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
LEARN ABOUT REDHAT
findbin
FindBin(3pm) Perl Programmers Reference Guide FindBin(3pm)
NAME
FindBin - Locate directory of original perl script
SYNOPSIS
use FindBin;
use lib "$FindBin::Bin/../lib";
or
use FindBin qw($Bin);
use lib "$Bin/../lib";
DESCRIPTION
Locates the full path to the script bin directory to allow the use of paths relative to the bin directory.
This allows a user to setup a directory tree for some software with directories <root>/bin and <root>/lib and then the above example will
allow the use of modules in the lib directory without knowing where the software tree is installed.
If perl is invoked using the -e option or the perl script is read from "STDIN" then FindBin sets both $Bin and $RealBin to the current
directory.
EXPORTABLE VARIABLES
$Bin - path to bin directory from where script was invoked
$Script - basename of script from which perl was invoked
$RealBin - $Bin with all links resolved
$RealScript - $Script with all links resolved
KNOWN ISSUES
If there are two modules using "FindBin" from different directories under the same interpreter, this won't work. Since "FindBin" uses
"BEGIN" block, it'll be executed only once, and only the first caller will get it right. This is a problem under mod_perl and other persis-
tent Perl environments, where you shouldn't use this module. Which also means that you should avoid using "FindBin" in modules that you
plan to put on CPAN. The only way to make sure that "FindBin" will work is to force the "BEGIN" block to be executed again:
delete $INC{'FindBin.pm'};
require FindBin;
KNOWN BUGS
If perl is invoked as
perl filename
and filename does not have executable rights and a program called filename exists in the users $ENV{PATH} which satisfies both -x and -T
then FindBin assumes that it was invoked via the $ENV{PATH}.
Workaround is to invoke perl as
perl ./filename
AUTHORS
FindBin is supported as part of the core perl distribution. Please send bug reports to <perlbug@perl.org> using the perlbug program
included with perl.
Graham Barr <gbarr@pobox.com> Nick Ing-Simmons <nik@tiuk.ti.com>
COPYRIGHT
Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. This program is free software; you can redistribute it and/or mod-
ify it under the same terms as Perl itself.
perl v5.8.0 2002-06-01 FindBin(3pm)