tags:

views:

186

answers:

1

I have some awk scripts that use gawk from cygwin. Now I need to pass these scripts to colleagues that don't have cygwin installed, but do have Perl. I was hoping I can just use a2p that is included in cygwin, but it fails with errors like the following:

Undefined subroutine &main::gensub called at ./t.pl line 18, <> line 1.

I am hoping there are existing Perl libraries/modules that implement these methods. Any pointers?

+5  A: 

The gensub() function isn't supported by a2p. If you modify your code to use gsub() instead then it should compile.

Alternatively, you could add a gensub() subroutine to the end of the translated Perl program to simulate the gensub() functionality.

However, the Perl code produced by a2p isn't very maintainable so I'd only use it as a last resort.

If your gawk program doesn't make calls to other cygwin/unix utilities then it would probably be better to just distribute a Windows gawk executable to your colleagues along with the program.

jmcnamara
Thanks for your response. I was also trying to learn a bit of perl using a2p. Your response helps.
Hemal Pandya