develooper Front page | perl.perl5.porters | Postings from August 2002

s2p change: no longer has switch parsing & stdin

Newton, Philip
August 7, 2002 03:03
s2p change: no longer has switch parsing & stdin
Message ID:
The original s2p (by Larry) as provided with, say, 5.6.1 takes options -n
and -p to specify whether the sed script to be converted is always or never
(respectively) called with the -n switch. If neither option is given, then
the conversion starts with a little bit of switch parsing.

This lets you convert a sed script which is sometimes called with -n and
sometimes without, into a Perl script which you can call with -n or without,
and it will emulate the corresponding sed behaviour. [I can't think of a
case off-hand where one would want to do that, but the possibility is

As far as I can see, you can't do that with the 5.8.0 s2p (aka psed);
rather, you have to specify -n or leave it out, and the script will then
only work with that case. I see no switch parsing.

Also, 5.6.1 s2p took the input (the sed script) from standard input (or,
according to the manpage, from the commandline, but I couldn't get that to
work in a quick test; the code produced printed every line of the input).
5.8.0's s2p takes the sed script from the command line (optionally preceded
by -e).

Of course, the documentation also changed to match the present behaviour,
but still... feels a little strange that the interface changed so
completely. (And a little functionality apparently got lost, too.)

Another change, I'd say, is the code that is output. 5.6.1's s2p produced
very simple code, that could, perhaps, introduce a sed scripter to some
basic Perl. The new s2p produces reams of code with weird functions and
lines such as

            if( exists( $wFiles{$$q} ) && $wFiles{$$q} ne '' ){
                open( $wFiles{$$q}, ">>$$q" );

I'm sure that works, but it's not really fun to behold for innocent
non-users of Perl.

Philip Newton        
datenrevision GmbH & Co. OHG
a gedas company                         TEL +49-40-797 007-37
Cuxhavener Str. 36, D-21149 Hamburg     FAX +49-40-797 007-10 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About