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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:13:36+00:00 2026-05-20T11:13:36+00:00

I have created a Perl file to load in an array of Stop words.

  • 0

I have created a Perl file to load in an array of “Stop words”.

Then I load in a directory with “.ner” files contained in it.
Each file gets opened and each word is split and compared to the words in the stop file.
If the word matches the word it is changed to “” (nothing-and gets removed)
I then copy the file to another location. So I can differentiate between files with stop words and files without.
But does this change the file to now contain no stop words or will it revert back to the original?

#!/usr/bin/perl

#use strict;
#use warnings;

my @stops;
my @file;

use File::Copy;

open( STOPWORD, "/Users/jen/stopWordList.txt" ) or die "Can't Open: $!\n";

@stops = <STOPWORD>;
while (<STOPWORD>)    #read each line into $_
{
    chomp @stops;     # Remove newline from $_
    push @stops, $_;  # add the line to @triggers
}

close STOPWORD;

$dirtoget="/Users/jen/temp/";

opendir(IMD, $dirtoget) || die("Cannot open directory");

@thefiles= readdir(IMD);

foreach $f (@thefiles){
    if ($f =~ m/\.ner$/){
        print $f,"\n";

        open (FILE, "/Users/jen/temp/$f")or die"Cannot open FILE"; 

        if ( FILE eq "" ) {
            close FILE;
        }
        else{
            while (<FILE>) {

               foreach $word(split(/\|/)){

                    foreach $x (@stops) {
                       if  ($x =~ m/\b\Q$word\E\b/) {
                            $word = '';   
             copy("/Users/jen/temp/$f","/Users/jen/correct/$f")or die "Copy failed: $!";
                    close FILE;
                    } 
                    }
                }
            }
        }
    }
}
closedir(IMD);
exit 0;

The format of the file I am splitting and comparing is as follows:

'<title>|NN|O Woman|NNP|O jumped|VBD|O for|IN|O life|NN|O after|IN|O firebomb|NN|O attack|NN|O -|:|O National|NNP|I-ORG News|NNP|I-ORG ,|,|I-ORG Frontpage|NNP|I-ORG -|:|I-ORG Independent.ie</title>|NNP|'

Should I be outlining where the words should be split ie: split(/|/)?

  • 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-05-20T11:13:37+00:00Added an answer on May 20, 2026 at 11:13 am

    @jenniem001,

    open FILE, ("<$fh")||die("cant");undef $/;my $whole_file = <FILE>;foreach my $word (@words){$whole_file=~s/\b\Q$word\E\b//ig;}open FILE (">>$duplicate")||die("cant");print FILE $whole_file;
    

    That will remove stops from your file and create a duplicate. Just call give $duplicate a name 🙂

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

Sidebar

Related Questions

I have created my own Perl module. I reference it from file Config.pm. When
I have created a C# class file by using a XSD-file as an input.
I have this perl code below, basically want to loop through these 2 files.
I am generating new xml file using perl script but I have small problem,
I have a Perl script that reads a command file and restarts itself if
I have created a script in Perl to connect to LDAP, retrieve values and
I have a log that gets created from a bunch of cron jobs. My
I have created an executable (.exe) of a perl script on a 64-bit linux
I have a PDF file (not created by me - I have no control
I have a perl script that append text on a file : open (EXFILE,

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.