[comp.lang.perl] Awk-to-perl translator bugs

nwinton@dalriada.axion.bt.co.uk (Neil Winton) (02/23/90)

Larry,

A couple more buglets for Patch 9 (or 10 if sizeof(Patch09) > ulimit! :-)

Given the following minimal awk script:

--------
{
	i = ($1 == "stop" && $2 == "now")
	if (i) exit 42;
}
--------

a2p throws up on line two.  It can't cope with logical expressions outside
an if/while/for.

If you comment out line 2, you then get:

--------
#!/usr/local/bin/perl
eval "exec /usr/local/bin/perl -S $0 $*"
    if $running_under_some_shell;
			# this emulates #! processing on NIH machines.
			# (remove #! line above if indigestible)

eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
			# process any FOO=bar switches

line: while (<>) {
    #	i = ($1 == "stop" && $2 == "now")
    if ($i) {
	ExitValue = 42; last line;
    }
}
exit ExitValue;
--------

As you will see, ExitValue is missing a $.

Trivia I know, but we're aiming for The Ultimate Tool here aren't we? :-)

	Neil

E-Mail (UUCP)  NWinton@axion.bt.co.uk (...!uunet!mcsun!axion.bt.co.uk!nwinton)
Organisation   British Telecom Research Laboratories (RT3134)
Snail Mail     306 SSTF, BTRL, Martlesham Heath, IPSWICH IP5 7RE, UK
Telephone      +44 473 646079 (or +44 473 643210)
*** This line intentionally left justified ***