PSH::PFE - Programmer's File Editor plugin for PSH.pm
Version 0.3
use PSH; use PSH::PFE; ... PSH::prompt;
psh$ ^OM File::Find psh$ ^QA \$(\w+) Replace: \U\$$1 =head1 DESCRIPTION
This module installs another special character into PSH, that allows you to easily send commands to PFE (Programmer's File Editor), to search&replace, open perl modules and other files etc. etc.
This is only an experimental version so do not expect too much. It was intended especialy to show you what can be done.
The module doesn't realy provide any functions to your script, it was meant to be used in pure psh. You add the commands defined here to PSH.pm by either
use PSH::PFE; or use PSH::PFE 'character';
This adds the character (by default '^') to PSH's specials and ties function &PSH::PFE to it. This function simply gets from PSH the rest of the line after the special character you specified and split's it on the first whitespace.
It then uses the first part as a name of a function in package PSH::PFE and passes the rest to it as it's only argument. The function name is uppercased before ussage!
The case of commands is unimportant !
psh$ ^QA regexp Replace: replacement string
This command searches the rest of the active document after cursor for the regexp and replaces it with the specified string.
It'as implemented as s/regexp/replacement/g.
psh$ ^QAi regexp Replace: replacement string
This command searches the rest of the active document after cursor for the regexp and replaces it with the specified string. The match is case insensitive.
It'as implemented as s/regexp/replacement/gi.
psh$ ^> $variable
psh$ ^> @variable
psh$ ^> code
Sets the variable to either the selected text or the current line. If the variable is a scalar it's set to the whole text. If it is an array it gets the text split into lines. If the parameter to the ^> command doesn't start with neither $ nor @ it's thought to be a function name.
^> $foo => eval "\$foo = <<'*EnD_DnE*';\n$text\n*EnD_DnE*\n" ^> @foo => eval "\@foo = split /\n/s, <<'*EnD_DnE*';\n$text\n*EnD_DnE*\n" ^> foo => eval "foo <<'*EnD_DnE*';\n$text\n*EnD_DnE*\n"
psh$ ^< $variable
psh$ ^< code
Evaluates the code and sends the result to PFE on the current position of cursor.