[plug] Perl 'tie' equivalent for Linux files (not a Perl question)

Trevor Phillips T.Phillips at murdoch.edu.au
Fri Oct 4 16:04:16 WST 2002


On Friday 04 October 2002 15:39, ryan at is.as.geeky.as wrote:
> 
> I want to 'tie' a script to a system file so that whenever that file is
> accessed the script is run and dumps its output into that file giving the
> impression the file is by all other means static.

I think what you're after can be done with Named Pipes in Perl. Not quite how 
you describe it, but can do what you want. Basically, you create a node, 
which acts as a FIFO to a Perl script, so reading from the file gets info 
from the script, and writing to it sends info to the script.

Simple uses include things like Fortune or Signature files which change each 
time you cat them, etc...

More info (found with Google - it's been a while since I experimented with 
this stuff):
   http://www.rocketaware.com/perl/perlipc/Named_Pipes.htm

There's an example in the Perl Cookbook as well, I believe...

Using this technique, you could either have a script directly generate the 
output on demand, or just cat another file, but use it as a trigger to 
regenerate the file.

-- 
. Trevor Phillips             -           http://jurai.murdoch.edu.au/ . 
: Web Technical Administrator     -          T.Phillips at murdoch.edu.au : 
| IT Services                        -              Murdoch University | 
 >--------------------------------------------------------------------<
| On nights such as this, evil deeds are done. And good deeds, of     /
| course. But mostly evil, on the whole.                             /
 \      -- (Terry Pratchett, Wyrd Sisters)                          /



More information about the plug mailing list