Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: remove non ascii characters in a whole corpus

by jonadab (Parson)
on Oct 25, 2014 at 13:30 UTC ( #1104961=note: print w/replies, xml ) Need Help??

in reply to remove non ascii characters in a whole corpus

There are several ways to approach that. Here are a couple of the easiest:

  • opendir will let you read the list of files in the source directory. You could then use a foreach loop to open each of them in turn, read the contents, do your transformation, open a corresponding file in the output directory, and write your transformed content to it.
  • You could also just use a pattern glob, perhaps something like this:
    foreach my $file (</path/to/sourcedir/*>) { # ... }
    This is slightly less portable (because the syntax of your glob is platform-dependent), and less flexible (because the glob is hardcoded, so it's harder to do things like read the source directory path from a config file), but for a quick-and-dirty hack, it's easier to get working quickly.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104961]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-12-07 20:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found