Using the subroutine get_login_env that was recommended to me in an earlier post I'm now having qualified success with my script. I think I understand the subsequent problem that I'm having and I hope that one of the Monastery's boffins can confirm my suspicion. My code has the following -
#!/usr/bin/perl -w # use strict ; # sub get_login_env { local %ENV; my $shell = shift || (getpwuid($<))[8]; my $env = `echo env | perl -e 'exec {"$shell"} -sh'`; if (wantarray) { my @pieces = ($env =~ m/^(.*?)=((?:[^\n\\]|\\.|\\\n)*)/gm); s/\\(.)/$1/g foreach @pieces; return @pieces; } else { return $env; } } # ############################################################### # Set up variables # ############################################################### # my $ftpfile = 'mailtest.pl' ; my $out_file = 'ronniesrubbish' ; my $result = 0 ; my $key = undef ; my $value = undef ; # print "\n\t\t<***** xxrcenv Starts *****>\n" ; # %ENV = (%ENV, get_login_env()); # while (($key, $value) = each (%ENV)) { print "\n\tKey :: $key" ; print "\n\tValue :: $value" ; } # print "\n" ; # use lib '/home/interface/sectran/lib' ; #use lib "$ENV{SECTRAN_DIR}/lib" ; foreach (@INC) { print "\t$_\n" ; }
This now works but originally the use lib was worded differently - use lib "$ENV{SECTRAN_DIR}/lib" ; This generated a compilation time error. Is this because the use lib is parsed at compile time and the SECTRAN_DIR variable is created at run time and therefore doesn't exist when the use lib is evaluated? Just trying to clear this up in my head. Cheers, Ronnie

In reply to UNIX/profile the sequel by Ronnie

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.