<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1015983" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1015983</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/update-line-and-then-replace-old-one#comment-1092784</link>
    <description> &lt;p&gt;Thanks Mark,&lt;/p&gt;
&lt;p&gt;works perfectly!! Thanks for your help...&lt;/p&gt;
&lt;p&gt;(It was chomp...)&lt;/p&gt;
 </description>
     <pubDate>Mon, 29 Oct 2001 23:34:08 +0000</pubDate>
 <dc:creator>rline</dc:creator>
 <guid isPermaLink="false">comment 1092784 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/update-line-and-then-replace-old-one#comment-1092763</link>
    <description> &lt;p&gt;try this:&lt;/p&gt;
&lt;p&gt;chop($line);&lt;br /&gt;
$line .= &quot;|$client_email\n&quot;;&lt;/p&gt;
&lt;p&gt;Or maybe it&#039;s chomp()... play with it and let me know.&lt;/p&gt;
&lt;p&gt;Docs: &lt;a href=&quot;http://www.perldoc.com/perl5.6/pod/func/chomp.html&quot; class=&quot;bb-url&quot;&gt;chomp()&lt;/a&gt;, &lt;a href=&quot;http://www.perldoc.com/perl5.6/pod/func/chop.html&quot; class=&quot;bb-url&quot;&gt;chop()&lt;/a&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 29 Oct 2001 17:03:55 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1092763 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/update-line-and-then-replace-old-one#comment-1092756</link>
    <description> &lt;p&gt;Thanks heaps Mark,&lt;/p&gt;
&lt;p&gt;It ALMOST works! The only thing it&#039;s doing wrong is this:&lt;/p&gt;
&lt;p&gt;$line .= &quot;|$client_email\n&quot;;&lt;/p&gt;
&lt;p&gt;It&#039;s writing $client_email onto the next line, instead of adding it to the end of the $line. I really don&#039;t know why. So if the old file had two lines, and line 1 gets a match, here&#039;s how it looks:&lt;/p&gt;
&lt;p&gt;OLD:&lt;/p&gt;
&lt;p&gt;field1|field2|field3&lt;br /&gt;
field1|field2|field3             # both these are distinct lines&lt;/p&gt;
&lt;p&gt;NEW:&lt;/p&gt;
&lt;p&gt;field1|field2|field3&lt;br /&gt;
client email&lt;br /&gt;
field1|field2|field3&lt;/p&gt;
&lt;p&gt;As you can see, client email is meant to hang on the end of the first line, but it ain&#039;t...If this can be fixed, it does the job perfectly...Any thoughts?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
 </description>
     <pubDate>Mon, 29 Oct 2001 08:36:02 +0000</pubDate>
 <dc:creator>rline</dc:creator>
 <guid isPermaLink="false">comment 1092756 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/update-line-and-then-replace-old-one#comment-1092707</link>
    <description> &lt;p&gt;I would read the file into an array.  Then loop through the array, looking for your criteria.  Once found, send your email, then alter that element in the array (thus altering the line in the file). Once you&#039;ve exited the loop, loop through the same array again, this time writting the array over top the file.&lt;/p&gt;
&lt;p&gt;pseudo-code:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;# suck the file into an array&lt;br /&gt;fopen(FILE, &amp;quot;&amp;lt;my_file.ext&amp;quot;);&lt;br /&gt;@file = &amp;lt;FILE&amp;gt;;&lt;br /&gt;close(FILE);&lt;br /&gt;&lt;br /&gt;# loop through lines&lt;br /&gt;foreach (@file as $line) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # run your criteria checks&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # this is a mock.. I have no idea how this will look&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($property eq $client_criteria) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # mail the client&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #( I forgot how 8P )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # add a flag to the line&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $line .= &amp;quot;|$client_email&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# write over the old file with your newly altered lines&lt;br /&gt;fopen(FILE,&amp;quot;&amp;gt;my_file.ext&amp;quot;);&lt;br /&gt;# loop through lines&lt;br /&gt;foreach (@file as $line) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print FILE $line;&lt;br /&gt;}&lt;br /&gt;close(FILE);&lt;/code&gt;&lt;/div&gt;&#039;A few things I&#039;m not sure of...&lt;br /&gt;
You may want a file lock, depends on how frequently the file will be accessed.  &lt;/p&gt;
&lt;p&gt;Also, I&#039;m not sure if you need to print a &quot;\n&quot; after $line when reqwriting the file.  I think each PRINT will make a new line, but if not add a &quot;\n&quot; to it.&lt;/p&gt;
&lt;p&gt;Hope that helps,&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Oct 2001 07:15:31 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1092707 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/update-line-and-then-replace-old-one#comment-1092699</link>
    <description> &lt;p&gt;Yeah I know. Sounds like it should be a piece of cake, but as ususal, not quite. Maybe I&#039;ll explain more what I&#039;m really trying to do, and you might know a really incredibly simple way of doing it, which bypasses all this...&lt;/p&gt;
&lt;p&gt;It&#039;s a script which looks at a file of properties available, as well as a file of property requirements that people have sent in via a form. So when this script runs, if it finds an available property, which has enough &quot;mathces&quot; with what the client wants in a property, it&#039;s a match, and the script then sends an email to the client telling them that there&#039;s a property they might be interested in. I can run the script as many or as few times as I want. But what I don&#039;t want is for the client to get more than one email about the same available property. In other words, once a match takes place, I need to do something, so that if I run the script one minute later, it notices that that combination of client and available property has already been matched, and therefore bypasses it.&lt;/p&gt;
&lt;p&gt;Does that make sense?&lt;/p&gt;
&lt;p&gt;That&#039;s all I&#039;m trying to do...and I&#039;m probably making it a lot harder than it needs to be.&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Oct 2001 02:43:13 +0000</pubDate>
 <dc:creator>rline</dc:creator>
 <guid isPermaLink="false">comment 1092699 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/update-line-and-then-replace-old-one#comment-1092698</link>
    <description> &lt;p&gt;How did you find that line in the first place?&lt;/p&gt;
&lt;p&gt;Loop through the file saving every line in an array except for the line that matches your previous criteria.  Then write the array to the file.&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Oct 2001 01:27:05 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1092698 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
