<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: perl question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117494#M150106</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can set environmental variables directly inside of your Perl script. Probably you should take a look at the %ENV hash, which Perl uses to store your current environment.  You can do this:&lt;BR /&gt;&lt;BR /&gt;$ENV{PATH} = "/bin:/usr/bin";&lt;BR /&gt;&lt;BR /&gt;to set an environment variable inside of your Perl script.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
    <pubDate>Wed, 12 Nov 2003 14:44:58 GMT</pubDate>
    <dc:creator>John Poff</dc:creator>
    <dc:date>2003-11-12T14:44:58Z</dc:date>
    <item>
      <title>perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117493#M150105</link>
      <description>I would like to run a shell script to setup environmental variables inside a perl script.&lt;BR /&gt;I try to use the system command, but my understanding of the system command is for it to spawn a child process and execute the script.  I need the environmental variable to be used for the perl script.  Thanks.</description>
      <pubDate>Wed, 12 Nov 2003 14:35:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117493#M150105</guid>
      <dc:creator>Charles Li_2</dc:creator>
      <dc:date>2003-11-12T14:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117494#M150106</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can set environmental variables directly inside of your Perl script. Probably you should take a look at the %ENV hash, which Perl uses to store your current environment.  You can do this:&lt;BR /&gt;&lt;BR /&gt;$ENV{PATH} = "/bin:/usr/bin";&lt;BR /&gt;&lt;BR /&gt;to set an environment variable inside of your Perl script.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Nov 2003 14:44:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117494#M150106</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-11-12T14:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117495#M150107</link>
      <description>This isn't so much a perl issue as it is a process issue. When a shell starts another shell (or perl routine), a copy of the environmental variables that are exported are made available to the new shell. Any changes to these do not effect the parent shell.&lt;BR /&gt; &lt;BR /&gt;In this situation I would write create a file under /tmp that sets the variables to their new values. Then after the perl script is run and the shell script is control, use the "." command to source in the /tmp file.&lt;BR /&gt; &lt;BR /&gt;example-&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;export x=1&lt;BR /&gt;perl myroutine&lt;BR /&gt;. /tmp/newvalues&lt;BR /&gt; &lt;BR /&gt;"myroutine" would build a file called /tmp/newvalues that would assign the variables. &lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 12 Nov 2003 14:47:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117495#M150107</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-12T14:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117496#M150108</link>
      <description>Attaching a script that displays these variables. &lt;BR /&gt;&lt;BR /&gt;it can be used to change them as well.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 12 Nov 2003 14:49:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117496#M150108</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-11-12T14:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117497#M150109</link>
      <description>I might not have explain this clearly.  &lt;BR /&gt;I have different scripts that sets the environmental variables depending on different situations.&lt;BR /&gt;When I run perl script #1 in a cron job, I would like to be able to call the set environmental script inside the perl script, so it can use the variables that I set.&lt;BR /&gt;Thanks.</description>
      <pubDate>Wed, 12 Nov 2003 15:07:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117497#M150109</guid>
      <dc:creator>Charles Li_2</dc:creator>
      <dc:date>2003-11-12T15:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117498#M150110</link>
      <description>As John already said, the ENVIRONMENT as known to *all* process types (shell, awk, sed, perl, compiled binaries, ...) is accessible in the perl hash %ENV.&lt;BR /&gt;&lt;BR /&gt;Inside this hash, you can *read* the environment variable by accessing that hash with the variable's name:&lt;BR /&gt;&lt;BR /&gt;my $user = $ENV{LOGNAME};&lt;BR /&gt;&lt;BR /&gt;as you would have written in a shell script&lt;BR /&gt;&lt;BR /&gt;export user=$LOGNAME&lt;BR /&gt;&lt;BR /&gt;You can *set* a variable, by assigning a value to the hash element:&lt;BR /&gt;&lt;BR /&gt;$ENV{LOGNAME} = getpwuid $&amp;lt;;&lt;BR /&gt;&lt;BR /&gt;as you would in the shell&lt;BR /&gt;&lt;BR /&gt;export LOGNAME=`logname`&lt;BR /&gt;&lt;BR /&gt;Now just remember that - whatever the language you program in - an environment variable only scopes to the process itself and its children (and their children), but *never* to the calling process.&lt;BR /&gt;&lt;BR /&gt;HTH, Enjoy, have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Nov 2003 15:29:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117498#M150110</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-11-12T15:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117499#M150111</link>
      <description>Charles,&lt;BR /&gt;&lt;BR /&gt;Merijn re-iterated my explaination. You can't change the variables of a parent shell from the child.&lt;BR /&gt; &lt;BR /&gt;I gave an example on how you could get the results you want...&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 12 Nov 2003 15:35:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117499#M150111</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-12T15:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117500#M150112</link>
      <description>In my example above-&lt;BR /&gt;. /tmp/newvalues&lt;BR /&gt; &lt;BR /&gt;Their is a space after ".". This is called sourcing a script. The script is not a child, but is run as the parent.&lt;BR /&gt; &lt;BR /&gt;Hope that helps explain it...&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 12 Nov 2003 15:37:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3117500#M150112</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-12T15:37:58Z</dc:date>
    </item>
  </channel>
</rss>

