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 9213127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:40:37+00:00 2026-06-18T01:40:37+00:00

I’m writing a code to find the file which not contain a string pattern.

  • 0

I’m writing a code to find the file which not contain a string pattern. Provided I have a list of files, I have to look into the content of each file, I would like to get the file name if the string pattern “clean” not appear inside the file. Pls help.

Here is the scenario:
I have a list of files, inside each file is having numerous of lines. If the file is clean, it will have the “clean” wording. But if the file is dirty, the “clean” wording not exist and there will be no clear indication to tell the file is dirty. So as long as inside each file, if the “clean” wording is not detect, I’ll category it as dirty file and I would like to trace the file name

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-06-18T01:40:38+00:00Added an answer on June 18, 2026 at 1:40 am

    If you need to generate the list within Perl, the File::Finder module will make life easy.

    Untested, but should work:

    use File::Finder;
    
    my @wanted = File::Finder              # finds all         ..
                  ->type( 'f' )            # .. files          ..
                  ->name( '*.txt' )        # .. ending in .txt ..
                  ->in( '.' )              # .. in current dir ..
                  ->not                    # .. that do not    ..
                  ->contains( qr/clean/ ); # .. contain "clean"
    
    print $_, "\n" for @wanted;
    

    Neat stuff!

    EDIT:

    Now that I have a clearer picture of the problem, I don’t think any module is necessary here:

    use strict;
    use warnings;
    
    my @files = glob '*.txt';  # Dirty & clean laundry
    
    my @dirty;
    
    foreach my $file ( @files ) {     # For each file ...
    
        local $/ = undef;             # Slurps the file in
        open my $fh, $file or die $!;
    
        unless ( <$fh> =~ /clean/ ) { # if the file isn't clean ..
            push @dirty, $file;       # .. it's dirty
        }
    
        close $fh;
    }
    
    print $_, "\n" for @dirty;        # Dirty laundry list
    

    Once you get the mechanics, this can be simplified a la grep, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in

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.