Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: remove non ascii characters in a whole corpus

by jonadab (Parson)
on Oct 25, 2014 at 13:30 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-18 05:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found