Okay I&#39;ll give that a try. I think that he wanted us to use the hash that was in the lesson. thanks again!<br><br>
<div><span class="gmail_quote">On 9/18/07, <b class="gmail_sendername">Frank Wiles</b> &lt;<a href="mailto:frank@wiles.org">frank@wiles.org</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On Tue, 18 Sep 2007 13:48:02 -0500<br>&quot;Emmanuel Mejias&quot; &lt;<a href="mailto:emmanuel.mejias@gmail.com">
emmanuel.mejias@gmail.com</a>&gt; wrote:<br><br>&gt; Cool! Thanks all for the feeback and links. I&#39;ve hit a few of those<br>&gt; in the past as well. I&#39;m like John as well, I need to do it to learn<br>&gt; it. I&#39;ve been in the BASH world so a lot of this stuff is new to me
<br>&gt; and I&#39;m trying to relate how some of the things you can do in Bash<br>&gt; how they work in Perl.<br>&gt;<br>&gt; Well here goes. I just recently started taking an online course in<br>&gt; Perl and I&#39;ve also been using Perl by Example book as a reference. In
<br>&gt; one of my exercises I have to write a script that prints out a sorted<br>&gt; list of environment variables. Well for some reason it is only<br>&gt; printing out 3 of the 5 that I specified. It doesn&#39;t matter what
<br>&gt; order I put the environment variables in, it just prints out every<br>&gt; other one. In this case it prints out HOME, HOSTNAME and USER, but<br>&gt; leaves out TERM and SHELL. What am I not doing right in my code?
<br>&gt;<br>&gt; #!/usr/bin/perl<br>&gt;<br>&gt; %env = (&#39;USER&#39;,<br>&gt; &#39;SHELL&#39;,<br>&gt; &#39;HOSTNAME&#39;,<br>&gt; &#39;TERM&#39;,<br>&gt; &#39;HOME&#39;);<br>&gt;<br>&gt; foreach $key (sort(keys(%env))){
<br>&gt; print &quot;$env $ENV{$key}\n&quot;;<br>&gt; }<br>&gt; Thoughts?<br><br>You&#39;re using a hash like an array when you shouldn&#39;t be:<br><br>What that is doing is creating this:<br><br>$env{USER} = &#39;SHELL&#39;;
<br>$env{HOSTNAME} = &#39;TERM&#39;;<br>$env{HOME} = &#39;&#39;;<br><br>Do this instead:<br><br>my @envs = qw( USER SHELL HOSTNAME TERM HOME );<br><br>foreach my $env ( @envs ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;print &quot;$env $ENV{$env}\n&quot;;
<br>}<br><br>-------------------------------------------------------<br>&nbsp;&nbsp;Frank Wiles, Revolution Systems, LLC.<br>&nbsp;&nbsp;&nbsp;&nbsp;Personal : <a href="mailto:frank@wiles.org">frank@wiles.org</a>&nbsp;&nbsp;<a href="http://www.wiles.org">http://www.wiles.org
</a><br>&nbsp;&nbsp;&nbsp;&nbsp;Work&nbsp;&nbsp;&nbsp;&nbsp; : <a href="mailto:frank@revsys.com">frank@revsys.com</a> <a href="http://www.revsys.com">http://www.revsys.com</a><br><br></blockquote></div><br>