About user tools - hakakou/optiperl GitHub Wiki
User tools are external programs that can be setup to run using custom parameters. If console programs are used (including perl scripts), you can also send and receive to standard input & output.
Parameters used can be changed dynamically, by replacing special tags listed in the next section.
You can also move your tools to toolbars or the menu, assign shortcuts and even a corresponding graphic.
For more advanced manipulating of optiperl read about plug-ins instead.
Why you would want to use tools - Some examples
Examples of non perl tools:
Opening an explorer window to c:\perl
Program: Explorer.exe
Parameters: c:\perl
Opening perl's main help file:
Program: Explorer.exe
Parameters: c:\perl\html\index.html
Starting and stopping apache
Program: c:\perl\bin\apache.exe
Parameters: -f "c:/perl/conf/httpd.conf"
Opening a console window at the folder of the active script in the editor
Program: cd
Parameters: "%folder%"
Creating a new email in Microsoft (r) Outlook (this will need MS-Office (r) installed) with the active file in the editor as an attachment.
Program: c:\program files\Microsoft Office\Office\Outlook.exe
Parameters: /a "%pathsn%"
Using pod2html
Program: c:\perl\bin\pod2html.bat
a) First method
Parameters: --infile=%PathSn% --outfile="%folder%\%FileNoExt%.html"
Notice the use of double quotes to make sure that paths with spaces are not interpreted from windows as multiple parameters.
The above will extract the pod text in your script in an html file. The file will be created in the same folder.
You could also set the above up so that the name of the output file is queried first:
-infile=%Pathsn% -outfile="%Querybox%"
b) Second method
Parameters: -infile=%PathSn% %n<pod - %filenoext%.html>%%getfile%
If you don't specify the -outfile in pod2html then the output is sent to standard output. The parameters %n<pod - %filenoext%.html>% and %getfile%
are "magic" which are deleted when running. They command optiperl:
%n<pod - %fileNoExt%>%
To open a new file in the editor named "pod - filename
" (without the extension)
%getfile%
To get all output and insert in the editor. This will capture all the output from pod2html.
Examples of perl tools:
Adding a tab character if front of each selected line
Program: TabIndentSelection.pl
Parameters: %SENDSELECTION%%GETSELECTION%
Enter the following for TabIndentSelection.pl:
# Get input from OptiPerl
Get input from OptiPerl
@lines = <STDIN>;
# Do now what you want with @lines and the rest of the variables
foreach (@lines) {
$_ = "\t" . $_;
}
#Send it back
print @lines;
Also see an implementation for CVS.