<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Need basic help with updating a file' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Need basic help with updating a file' posted on the 'Perl' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 22:58:34 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 22:58:34 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Need basic help with updating a file</title>
      <link>http://www.programmersheaven.com/mb/perl/414313/414313/need-basic-help-with-updating-a-file/</link>
      <description>I am writing a script for my two little boys to play a game. We&lt;br /&gt;
are not going to hack ourself so I am not doing strict etc. I mention &lt;br /&gt;
this because previous attempts to get help did not get the question&lt;br /&gt;
answered elsewhere,but referred to do strict and warnings. There is a ton more code than what I am going to show you...a re-write to strict would take a long time...not merited for a script for only use on a home system.&lt;br /&gt;
&lt;br /&gt;
Scratch.dat is a dat file with 18 lines...&lt;br /&gt;
the_line|country_number&lt;br /&gt;
&lt;br /&gt;
country.dat is also a dat file with 336 lines...&lt;br /&gt;
ln|nm|nr|ne|ea|se|so|sw|we|nw|mn|tt&lt;br /&gt;
&lt;br /&gt;
I want to read all 18 lines of scratch.dat and update country.dat&lt;br /&gt;
so that if scratch.dat (country_number) is equal to country.dat (ln),&lt;br /&gt;
then country.dat (mn) would be changed to the value of scratch.dat&lt;br /&gt;
(the_line)...I need help with printing the updated country.dat file&lt;br /&gt;
back.&lt;br /&gt;
&lt;br /&gt;
Please help me with this.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;# Have 18 rand numbers, now assign creatures to countrys
open (SCR, "scratch.dat") || &amp;amp;CgiDie ("SCRATCH could not be opened while attempting read");
        @scra =&amp;lt;SCR&amp;gt;;
        close (SCR);
        $reps = 1;
        while ($reps &amp;lt; 19)
        {
        foreach $mine (@scra)
            {
            chomp($mine);
            ($the_line, $country_number) = split (/\|/, $mine);
            open (CNT, "+&amp;gt;country.dat") || &amp;amp;CgiDie ("Country list could not be opened trying to position creatures");
            @ymca =&amp;lt;CNT&amp;gt;;
            foreach $thine (@ymca)
                {
                chomp($thine);
                ($ln, $nm, $nr, $ne, $ea, $se, $so, $sw, $we, $nw, $mn, $tt ) = split (/\|/, $thine);
                if ($ln == $country_number)
                    {
                    $mn = $the_line;
                    }
                } # End of for each on country file
            $reps++;
            } # End of for each @scra - scratch
            print CNT;
            close (CNT);
        } # End of while
    #unlink ("scratch.dat");
    &amp;amp;printout;
    }
else
    {
    &amp;amp;signin;
        }&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/414313/414313/need-basic-help-with-updating-a-file/</guid>
      <pubDate>Mon, 08 Mar 2010 12:29:32 -0700</pubDate>
      <category>Perl</category>
    </item>
  </channel>
</rss>
