Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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.

HTH.HAND.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2019-12-05 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (151 votes). Check out past polls.

    Notices?