If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Searching a pattern in multiple files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-19-09, 13:33
dbsam dbsam is offline
Registered User
 
Join Date: Dec 2009
Posts: 31
Searching a pattern in multiple files

Hi.. I am new to perl but I know there is a simple solution of the problem I am stating below. I am searching for a text pattern in mutliple files of a folder , once I find it I need to parse it in a variable and write it as a header in an excel file. Please somebody help

Thanks

Sam
Reply With Quote
  #2 (permalink)  
Old 12-22-09, 08:38
scooby_at_work scooby_at_work is offline
Registered User
 
Join Date: Sep 2009
Posts: 44
This will make a fake .xls (really a tab delimited file, but Excel will handle it just fine) based on the contents of *.files. You can specify multiple files or whatever (it's all handled by the -n option) if you want.

It is possible to write out a proper Excel file, but you'll need to install a separate module.

Code:
perl -n -e 'push @a, $1 if /pattern(capture stuff)/; END { print join("\t", @a)."\n"; }' *.files > foo.xls
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On