SPUG: Inline::Files

Brian Ingerson briani at activestate.com
Fri May 25 20:14:22 CDT 2001


As I pen this message Inline::Files is populating CPAN mirrors
wordwide...

Inline::Files is a new module by Damian Conway. In the strict sense it
has nothing to do with the usual Inline::* crowd. 'Files' is not the
name of any programming language that I know of. So what is it then?

Remember the good old DATA file handle? That's the one that
automatically gets opened with the contents of your Perl script that
fall after a line containing only '__DATA__' or '__END__'. It sure is a
handy little feature. But it doesn't scale. What do I mean? Well there's
just one of them and you can only *read* from it and ...

 &^%%(&%)(*(@$^&^$ Shazaam! Enter Inline::Files!

With Inline::Files you can:

- Have as many __FOO__ delineated files in your program as you want.
- Have more than one with the *same* marker name.
- No __END__ or __DATA__ markers required.
- Use them just like DATA. No open required.
- Open them if you want to.
- Read from them.
- Write to them!
- Read and write at the same time.
- Seek on them.
- Tell on them. (You tattler you)
- Truncate them.
- Close them.
- Open/create brand new ones on the fly.
- Delete (unlink) them. (Coming soon...)
- Treat them almost exactly like regular files...
- But on steroids!
- And more.

Why? Because this is Perl! The Script *IS* the File System.

---

Those of you who have used Inline.pm will be familiar with this style.
Does Inline support Inline::Files? Good question. Of course it does! The
upcoming 0.40 super-release has preliminary support.

    use Inline::Files;
    use Inline C;
    
    print "9 + 16 = ", add(9, 16), "\n";
    
    __C__
    int add(int x, int y) {
        return x + y;
    }

"Look ma, no __END__ statement". Although that's not the strongest case
for I::F, there are some subtle andvantages. Now the source code can
truly be compiled/loaded at Perl compile time instead of an INIT block.
That means prototyped/bareword Inline functions can be used. Also I::F
can report the *real* starting line and filename of the virtual file.
This will be used to report that actual error location on C and C++
compilation failures. 

Beyond Inline, I see no end of usefulness for Inline::Files. The "Good
Doctor" has done it again!

Cheers, Brian Ingerson
ingy at cpan.org

-- 
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list