Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:

This is more a UNIX question than strictly a perl one, but could I get vi or pico or whatever to read the output of a perl script rather than a file? Something like "pico | decrypt.pl"? Then I could have encrypted files on disk, read them, decrypted, on the fly so that the decrypted version never exists on disk, only in RAM?


($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print

Replies are listed 'Best First'.
Re: can a text editor read from perl output?
by kvale (Monsignor) on Nov 06, 2004 at 05:08 UTC
    This seems to work with gvim:
    perl -e 'print "hello\n"' | gvim -
    The trailing - is a pipe designator for many Unix programs.

    -Mark

Re: can a text editor read from perl output?
by Zed_Lopez (Chaplain) on Nov 06, 2004 at 06:23 UTC
Re: can a text editor read from perl output?
by neniro (Priest) on Nov 06, 2004 at 10:49 UTC
    Using vi(m) you can insert the output of an external command easily using this vi-command:
    :.!myscript.pl
    and of course you can use an external script to modify specified lines in your actual buffer:
    :1,$!sort
    This Wikipedia-article shows a lot of the powerful features you can use within vi(m).
    You can use :help command to get help directly in vi(m).

    UPDATE: Changed link to non-german Wikipedia.

Re: can a text editor read from perl output?
by Aighearach (Initiate) on Nov 06, 2004 at 05:29 UTC
    With vi you can just use - to tell it that the file is on stdin. And just pipe it in.
    decrypt.pl | vi -
    Pico is even easier.
    decrypt.pl | pico

    Update: Well, even though I'm an emacs user, I don't see an obvious way to do this. There are probably 100 ways to do it. But good luck...


    --
    Snazzy tagline here
Re: can a text editor read from perl output?
by ikegami (Patriarch) on Nov 06, 2004 at 06:08 UTC

    Keep in mind that anyone who could have read the temporary file can still do so by reading the memory used by the editor process.

    If you want to be able to make changes to the file, you could try using a named pipe. I don't know if it would work, and I'm too tired to try rght now, but it's something that might be worth looking into. Be careful to make it so only you can access said named pipe.

      re read memory: ... or the swap file.