Skip to content

Files and EDIT

Brett Estrade edited this page Nov 18, 2026 · 2 revisions

Files and EDIT

Bring an existing .pl into memory

LOAD "my program.pl"
LIST
EDIT
RUN
SAVE

LOAD gives ordinary source editing numbers 10, 20, 30, ... . Comments, blank lines, and indentation are retained. Loading and editing do not execute or syntax-check the program; even incomplete source may be kept in memory.

RUN evaluates the whole program together. Its input is a string evaluation, not a fresh perl filename.pl process: package state is shared with the session, and AnteREPL's default pragmas apply. Files that depend on script startup behavior, their own __DATA__ handle, or unusual compile-time context may need adaptation. Use !! perl filename.pl when you want a separate script process with normal terminal I/O.

IMPORT filename.pl is also available. It creates an unsaved copy and does not remember the original filename as a SAVE destination.

Choose a save format

Command What it writes
SAVE demo.bperl Native header and numbered source
SAVE demo.pl Ordinary source without editing numbers or extra pragmas
SAVE Last SAVE/LOAD filename and format
SAVE other.txt Current format; native for a newly created program
EXPORT demo.pl Ordinary source plus AnteREPL's default-pragmas prelude

SAVE remembers an absolute filename, so changing directory afterward does not redirect a filename-less SAVE. EXPORT does not change the remembered SAVE destination or mark the numbered program saved.

Loading .bperl requires its native header, # PERL ANTE REPL V0.1. Legacy # BASIC PERL V0.1 files remain readable; native-format saves write the current header. Either header identifies native numbered source regardless of the filename extension. Malformed records or duplicate numbers leave the current program intact.

Files are UTF-8. CRLF is accepted on input and normalized to LF; each stored physical line ends with a newline when saved. NUL and bare carriage returns are rejected. Source files do not serialize live variables, functions created only at the prompt, or %ENV.

The EDIT round trip

  1. AnteREPL writes the in-memory source to a private temporary program.pl, without editing numbers.
  2. It opens that file using $EDITOR, then $VISUAL, then vi on Unix or notepad on Windows.
  3. You edit, save, and close the editor.
  4. AnteREPL reloads changed source into memory, numbered 10, 20, 30, ... .
  5. Use RUN to try it and SAVE to write your program file.

If the contents did not change, the existing numbers are retained. UNDO restores a changed program and its earlier numbering in one step. Editor failure, nonzero exit, missing/unreadable output, or invalid text leaves the program unchanged. An intentionally empty editor file clears the program.

You can change editors during a session:

$ENV{EDITOR} = 'vim';
$ENV{EDITOR} = 'code --wait';
$ENV{EDITOR} = '"C:/Program Files/My Editor/editor.exe" --wait';

Choose one setting appropriate for the editor you have. GUI editors need a wait option so AnteREPL reloads only after editing finishes. The setting is parsed as an executable and arguments, without shell expansion, pipes, or redirection. Use a wrapper program when you need more elaborate startup logic.

Keep or discard changes deliberately

LOAD, IMPORT, NEW/CLEAR, and QUIT/EXIT refuse to discard unsaved source. Save first, or explicitly use LOAD!, IMPORT!, NEW!, CLEAR!, QUIT!, or EXIT!. A force suffix is not supported on other commands.

SAVE and EXPORT replace their destination file. Writes use a temporary file followed by a rename. UNDO keeps up to 50 source changes; it does not undo file writes or executed Perl, and does not restore an earlier filename. There is no automatic recovery after a crash or forced termination.

Clone this wiki locally