That's the most logical answer, and I'd stick to that for all but exceptional circumstances. The two alternative ways to do it that I know of are:
- maybe still possible to use perl + c code to do what I did years ago in C alone: look up the memory location of a system level variable and change it directly. not recommended.
- in unix/linux most shells you can use backticks to evaluate (possibly nested) calls to programs or regexes etc. and receive the value during a particular evaluation nest level, to set a shell variable for instance, e.g.
set str3=`perl my_whatever_perl_script.pl` export str3
depends which shell as to what exact syntax, but the backticks should work. your perl script should return as an exit value the value you want assigned to the shell variable.
the second alternative is quite usable in situations where it's absolutely necessary.
the hardest line to type correctly is: stty erase ^H

In reply to Re^8: pass perl variable to shell script by aquarium
in thread pass perl variable to shell script by arthurs

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.