The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

rep.pl - perform a series of find an replaces

SYNOPSIS

  perl rep.pl --backup <backup_file> --substitutions <substitutions_file> --target <file_to_act_on>

  perl rep.pl -b <backup_file> -f <file_to_act_on> 's/foo/bar'

USAGE

  rep.pl -[options] [arguments]

  Options:

     -s                substitutions list file
     --substitutions   same
     -f                target file name to be modified
     --target          same
     -B                backup file name
     --backup          same

     -d                debug messages on
     --debug           same
     -h                help (show usage)
     -v                show version
     --version         show version

DESCRIPTION

rep.pl is a script which does finds and replaces on a file, and records the beginning and end points of the modified strings.

It is intended to act as an intermediary between Emacs::Rep and the emacs lisp code which drives the "rep" process.

Emacs can then use the recorded locations to highlight the changed regions, and it can use information about what was replaced to perform undo operations.

The elisp code must choose a unique backup file name. This makes it possible to do reverts of an entire run of substitutions.

  perl rep.pl --backup <backup_file> --substitutions <substitutions_file> --target <file_to_act_on>

The script returns a serialized data dump of the history of the changes to the text, in a form that looks like this:

  0:303:308:1:cars;
  1:83:116:8:of;
  1:113:123:8:of;
  1:171:181:8:of;
  1:431:441:8:of;
  1:596:606:8:of;
  2:61:86:23:.;
  2:330:355:23:.;
  2:639:664:23:.;
  2:889:914:23:.;
  3:702:711:0:evening;
  4:855:863:4:cane;

The first field corresponds to the "pass" through the file (one pass per substitution command) The second and third fields are the begin and end points of the changed strings, counting from 1. The fourth field is the size of the "delta", the change in length due to the modification. The fifth field is the originally matched string, before the change. Note: this field may contain a colon. Any separators after the fourth should be ignored.

(( documentation inside Rep.pm is more up-to-date TODO centralize that somewhere. A lone pod file? ))

AUTHOR

Joseph Brenner, <doom@kzsu.stanford.edu>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Joseph Brenner

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

BUGS

None reported... yet.