develooper Front page | perl.inline | Postings from August 2001

Inline::AWK

From:
John McNamara
Date:
August 10, 2001 04:02
Subject:
Inline::AWK
Message ID:
01081012001501.03074@fano

As a result of a conversation with Brian Ingerson at YAPC::Eu last
week I have written an Inline ILSM for Awk.

From the manpage:

NAME
       Inline::AWK - Add Awk code to your Perl programs.


SYNOPSIS
       Call functions written in Awk from your Perl program as
       follows:

	   use Inline AWK;

	   hello("Awk");

	   __END__
	   __AWK__

	   function hello(str) {
	       print "Hello " str
	   }


DESCRIPTION
       The Inline::AWK module allows you to include Awk code in
       your Perl program.

       This release only supports functions written in Awk. The
       next release will support entire Awk programs as well as
       functions.

       Inline::AWK works by filtering Awk code through the Perl
       utility `a2p'. The `a2p' utility comes as standard with
       all Perl distributions.

TODO
       This is alpha code so there are lots of things outstand­
       ing:

       · Deal with entire programs as well as functions. This is
         quite easy to do. I just didn't have time.

       · Test the module against more existing Awk code.


AUTHOR
       John McNamara jmcnamara@cpan.org



The code is alpha. It is working but I need to deal with a few more
implementation details and do some more testing. The module is
available from:
http://homepage.eircom.net/~jmcnamara/perl/Inline-AWK-0.01.tar.gz

There are several example programs included with the distro. 
NOTE: Unix users. I managed to dosify the example files so you will
have to run them through dos2unix before they will compile. I'll fix
this tonight.

ActivePerl users can use PPM as follows:

    C:\> ppm
    PPM> set repository tmp http://homepage.eircom.net/~jmcnamara/perl
    PPM> install Inline-AWK
    PPM> quit
    C:\>

    If this fails try the following:

    PPM>install http://homepage.eircom.net/~jmcnamara/perl/Inline-AWK.ppd


The utility of this module is questionable: it doesn't do anything
more than you can already do with a2p; you can do something similar
with Filter::exec "a2p"; and even without a2p it's generally easy to
translate Awk code to Perl code.

However, I am fond of Awk and if nothing else it will give Brian
Ingerson an extra bullet point on his Inline Languages slide.

Also, Inline::AWK serves as an atonement for Inline::PERL. ;-)

John.
-- 
perl -e 'use Inline AWK=>q+function j(){print"Just Another Awk Hacker"}+;j'







nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About