Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 43945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:34:30+00:00 2026-05-10T15:34:30+00:00

I have a bunch of PDF files and my Perl program needs to do

  • 0

I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string. To date I have been using this:

my @search_results = `grep -i -l \'$string\' *.pdf`; 

where $string is the text to look for. However this fails for most pdf’s because the file format is obviously not ASCII.

What can I do that’s easiest?

Clarification: There are about 300 pdf’s whose name I do not know in advance. PDF::Core is probably overkill. I am trying to get pdftotext and grep to play nice with each other given I don’t know the names of the pdf’s, I can’t find the right syntax yet.

Final solution using Adam Bellaire’s suggestion below:

@search_results = `for i in \$( ls ); do pdftotext \$i - | grep --label='\$i' -i -l '$search_string'; done`; 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:34:30+00:00Added an answer on May 10, 2026 at 3:34 pm

    The PerlMonks thread here talks about this problem.

    It seems that for your situation, it might be simplest to get pdftotext (the command line tool), then you can do something like:

    my @search_results = `pdftotext myfile.pdf - | grep -i -l \'$string\'`; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of PDF documents and all of them contain a title
I have a bunch of PDF docs with tabular data in them which I
I have a bunch of pdf files that starts with a unique number. And
I have a bunch of PDF files that came from scanned documents. The files
I have a bunch of PDF files that I need to convert to TXT.
Have a bunch of pdf files I want to display on a web page
I have a bunch of PDF files that I receive once a week. Some
In a directory, I have a bunch of files like file1.tex, file1.pdf, file2.tex, file2.pdf
We have bunch of Domain Entities which should be rendered to an html format,
I have a bunch of named value parameters in a Dictionary<string, object> , which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.