<?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: help me understand this perl one liner in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006851#M98833</link>
    <description>Thanks Hein, for your time .i hope i will be able to write the program as you showed in this case</description>
    <pubDate>Thu, 05 Oct 2006 11:45:47 GMT</pubDate>
    <dc:creator>Abdul khadeer_1</dc:creator>
    <dc:date>2006-10-05T11:45:47Z</dc:date>
    <item>
      <title>help me understand this perl one liner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006849#M98831</link>
      <description>Hi,&lt;BR /&gt;in this thread &lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1065208" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1065208&lt;/A&gt;&lt;BR /&gt;i saw the solution to problem as &lt;BR /&gt;#perl -ne '($h,$n)=split; if ($old=$o{$h}) {print "$h : ", $n - $old, "\n"} else {$o{$h}=$n}' file1.txt file2.txt&lt;BR /&gt;what does $h,$n where does the values are stored after the lines in the files file1.txt,file.txt are splited according to space " " .&lt;BR /&gt;how is %o association being formed in this case i believe that is what you are refering by saying the $o{$h} . After the condition is true you are trying to substract $n[0]..that would be 10 or 15 and you are refering the $o{$h} is the same value if the association is being formed from spilt.&lt;BR /&gt;Thanks for your help in advance&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Oct 2006 15:48:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006849#M98831</guid>
      <dc:creator>Abdul khadeer_1</dc:creator>
      <dc:date>2006-10-04T15:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: help me understand this perl one liner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006850#M98832</link>
      <description>Hello again Abdul,&lt;BR /&gt;&lt;BR /&gt;And I actually had a bit of comment/explanation with the original topic.&lt;BR /&gt;&lt;BR /&gt;Anyway, let me re-arrange the code and add comment some more:&lt;BR /&gt;&lt;BR /&gt;1) perl -ne '&lt;PROG&gt;' file1.txt file2.txt&lt;BR /&gt;&lt;BR /&gt;Execute 'prog' perl in an implied loop reading through all input files, setting variable $_ to the next line in the input for each iteration.&lt;BR /&gt;&lt;BR /&gt;2) ($h,$n)=split;  &lt;BR /&gt;&lt;BR /&gt;As you indicate, split data from default variable $_ using default 'whitespace' seperators. Here $h = host, $n = number.&lt;BR /&gt;&lt;BR /&gt;3) if ($old=$o{$h}) &lt;BR /&gt;&lt;BR /&gt;%o is an associative array.&lt;BR /&gt;$o{$h} is an element from %o with key value $h (here host)&lt;BR /&gt;So this TRIES to pick an already stored number for host.&lt;BR /&gt;If that worked THEN&lt;BR /&gt;&lt;BR /&gt;4) {print "$h : ", $n - $old, "\n"} &lt;BR /&gt;&lt;BR /&gt;Print the host name and the difference between the current number and the old, already remembered number.&lt;BR /&gt;&lt;BR /&gt;5) else {$o{$h}=$n}&lt;BR /&gt;&lt;BR /&gt;ELSE... if there was no old number saved for host $h, then save it now: Create and element with key $h and value $n in array %o&lt;BR /&gt;&lt;BR /&gt;Sort of.. but through variables...  do:&lt;BR /&gt; %o{"host1-80"} = 20;&lt;BR /&gt;&lt;BR /&gt;More clear?&lt;BR /&gt;&lt;BR /&gt;Anyone else see anythign that needs explanation here?&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PROG&gt;</description>
      <pubDate>Wed, 04 Oct 2006 17:44:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006850#M98832</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-10-04T17:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: help me understand this perl one liner</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006851#M98833</link>
      <description>Thanks Hein, for your time .i hope i will be able to write the program as you showed in this case</description>
      <pubDate>Thu, 05 Oct 2006 11:45:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-me-understand-this-perl-one-liner/m-p/5006851#M98833</guid>
      <dc:creator>Abdul khadeer_1</dc:creator>
      <dc:date>2006-10-05T11:45:47Z</dc:date>
    </item>
  </channel>
</rss>

