s2p - Sed to Perl translator


s2p [options] filename


S2p takes a sed script specified on the command line (or from standard input) and produces a comparable perl script on the standard output.


Options include:


sets debugging flags.


specifies that this sed script was always invoked with a sed -n. Otherwise a switch parser is prepended to the front of the script.


specifies that this sed script was never invoked with a sed -n. Otherwise a switch parser is prepended to the front of the script.


The perl script produced looks very sed-ish, and there may very well be better ways to express what you want to do in perl. For instance, s2p does not make any use of the split operator, but you might want to.

The perl script you end up with may be either faster or slower than the original sed script. If you're only interested in speed you'll just have to try it both ways. Of course, if you want to do something sed doesn't do, you have no choice. It's often possible to speed up the perl script by various methods, such as deleting all references to $\ and chop.


S2p uses no environment variables.


Larry Wall <>



 perl   The perl compiler/interpreter
 a2p    awk to perl translator




We are painfully aware that these documents may contain incorrect links and misformatted HTML. Such bugs lie in the automatic translation process that automatically created the hundreds and hundreds of separate documents that you find here. Please do not report link or formatting bugs, because we cannot fix per-document problems. The only bug reports that will help us are those that supply working patches to the installhtml or pod2html programs, or to the Pod::HTML module itself, for which I and the entire Perl community will shower you with thanks and praises.

If rather than formatting bugs, you encounter substantive content errors in these documents, such as mistakes in the explanations or code, please use the perlbug utility included with the Perl distribution.

--Tom Christiansen, Perl Documentation Compiler and Editor

Return to the Perl Documentation Index.
Return to the Perl Home Page.