Skip to main content
better text
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20

Note because files are slurp()-ed in (i.e. read into memory all at once), you might run into memory limits for exceedingly large files. This could be circumvented by opening a filehandle and appending modified lines linewise (however, you'll lose the ability to doin general this makes multi-line substitutions more complicated). See https://docs.raku.org/language/io-guide for details.

Note because files are slurp()-ed in (i.e. read into memory all at once), you might run into memory limits for exceedingly large files. This could be circumvented by opening a filehandle and appending modified lines linewise (however, you'll lose the ability to do multi-line substitutions). See https://docs.raku.org/language/io-guide for details.

Note because files are slurp()-ed in (i.e. read into memory all at once), you might run into memory limits for exceedingly large files. This could be circumvented by opening a filehandle and appending modified lines linewise (however, in general this makes multi-line substitutions more complicated). See https://docs.raku.org/language/io-guide for details.

better formatting
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20
  1. First of all, the code above is fairly tight, and can be entered on the command line (suggestions welcome for making it tighter).
  2. Second of all the code above requires no external modules be loaded.
  3. Third of all directories with convoluted filenames can be easily interrogated/modified, because Raku's dir() method can specify filenames via Regex. You'll appreciate the ability to specify all-at-once (for example) case-insensitive multiple extensions: dir(test => /:i \. [ html | htmx | shtml | htm | xhtml ] $/).
  4. You can specify filenames on-the-fly, for example adding a .mod tag to the end of a newly-created/modified file. This helps you keep track of your progress without ever having to call rename at the end of your work.
  5. Raku provides high-level Unicode support, meaning you can perform Unicode substitutions robustly. You have your choice of NFC-normalizing your Unicode, or reconstructing the input bytes using an encoding called UTF8-C8. See Unicode link below for details.
  6. Finally, the code above can easily be run from a stand-alone script. For portability, use the code with the $*CWD dynamic variable, navigating to the directory-of-interest. Otherwise, Raku provides the indir() method, which allows you to overwrite $*CWD and run the modification script from (virtually) anywhere in your filesystem. See the indir() link below for details.
  dir(test => /:i  \. [ html | htmx | shtml | htm | xhtml ] $/)
  1. You can specify filenames on-the-fly, for example adding a .mod tag to the end of a newly-created/modified file. This helps you keep track of your progress without ever having to call rename at the end of your work.
  2. Raku provides high-level Unicode support, meaning you can perform Unicode substitutions robustly. You have your choice of NFC-normalizing your Unicode, or reconstructing the input bytes using an encoding called UTF8-C8. See Unicode link below for details.
  3. Finally, the code above can easily be run from a stand-alone script. For portability, use the code with the $*CWD dynamic variable, navigating to the directory-of-interest. Otherwise, Raku provides the indir() method, which allows you to overwrite $*CWD and run the modification script from (virtually) anywhere in your filesystem. See the indir() link below for details.
  1. First of all, the code above is fairly tight, and can be entered on the command line (suggestions welcome for making it tighter).
  2. Second of all the code above requires no external modules be loaded.
  3. Third of all directories with convoluted filenames can be easily interrogated/modified, because Raku's dir() method can specify filenames via Regex. You'll appreciate the ability to specify all-at-once (for example) case-insensitive multiple extensions: dir(test => /:i \. [ html | htmx | shtml | htm | xhtml ] $/).
  4. You can specify filenames on-the-fly, for example adding a .mod tag to the end of a newly-created/modified file. This helps you keep track of your progress without ever having to call rename at the end of your work.
  5. Raku provides high-level Unicode support, meaning you can perform Unicode substitutions robustly. You have your choice of NFC-normalizing your Unicode, or reconstructing the input bytes using an encoding called UTF8-C8. See Unicode link below for details.
  6. Finally, the code above can easily be run from a stand-alone script. For portability, use the code with the $*CWD dynamic variable, navigating to the directory-of-interest. Otherwise, Raku provides the indir() method, which allows you to overwrite $*CWD and run the modification script from (virtually) anywhere in your filesystem. See the indir() link below for details.
  1. First of all, the code above is fairly tight, and can be entered on the command line (suggestions welcome for making it tighter).
  2. Second of all the code above requires no external modules be loaded.
  3. Third of all directories with convoluted filenames can be easily interrogated/modified, because Raku's dir() method can specify filenames via Regex. You'll appreciate the ability to specify all-at-once (for example) case-insensitive multiple extensions:
  dir(test => /:i  \. [ html | htmx | shtml | htm | xhtml ] $/)
  1. You can specify filenames on-the-fly, for example adding a .mod tag to the end of a newly-created/modified file. This helps you keep track of your progress without ever having to call rename at the end of your work.
  2. Raku provides high-level Unicode support, meaning you can perform Unicode substitutions robustly. You have your choice of NFC-normalizing your Unicode, or reconstructing the input bytes using an encoding called UTF8-C8. See Unicode link below for details.
  3. Finally, the code above can easily be run from a stand-alone script. For portability, use the code with the $*CWD dynamic variable, navigating to the directory-of-interest. Otherwise, Raku provides the indir() method, which allows you to overwrite $*CWD and run the modification script from (virtually) anywhere in your filesystem. See the indir() link below for details.
added 29 characters in body
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20
  • Complete the circle by replacing the original file (start from same $*CWD as above), then delete the .mod file:
  • Complete the circle by replacing the original file (start from same $*CWD as above):
  • Complete the circle by replacing the original file (start from same $*CWD as above), then delete the .mod file:
added 1 character in body
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20
Loading
better text
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20
Loading
Improve formatting.
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20
Loading
Source Link
jubilatious1
  • 3.9k
  • 10
  • 20
Loading