If you want the perl script to modify the parent shell's environment, there is a way, but the two processes have to cooperate.

The basic idea is that the subprocess--the perl script--should print shell commands to its stdout, which the parent process--the shell--would capture and execute. For instance, here's a trival script to set your terminal type:

#!/usr/local/bin/perl print "TERM=", $ARGV[0], " export TERM\n";
Run it like this:
eval `myterm vt100`
and your shell will dutifully set its TERM variable to vt100 (assuming you're using a bourne-like shell).

The subprocess may need to look at the SHELL environment variable so that it can produce sh or csh style output as appropriate. And the user wanting to use this command may want to set up an alias or shell function to make the command easier to type.

The unix "resize" command uses this technique. You should take a look at its man page.


In reply to Re: sourcing by kjherron
in thread sourcing by trschau

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.