<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1012628" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1012628</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/local#comment-1073121</link>
    <description> &lt;p&gt;We all make typos when we&#039;re out of coffee.&lt;/p&gt;
 </description>
     <pubDate>Sat, 21 Oct 2000 05:08:56 +0000</pubDate>
 <dc:creator>Orpheus</dc:creator>
 <guid isPermaLink="false">comment 1073121 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>backwards ;)</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/local#comment-1073065</link>
    <description> &lt;p&gt;You have it a bit backwards, then, Orpheus... &lt;strong&gt;$\&lt;/strong&gt; is&lt;br /&gt;
the output record separator.  That is:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;print 1; print 2; print 3; # prints &amp;quot;123&amp;quot;&lt;br /&gt;$\ = &amp;quot;#&amp;quot;;&lt;br /&gt;print 1; print 2; print 3; # prints &amp;quot;1#2#3#&amp;quot;&lt;br /&gt;$\ = &amp;quot; &amp;quot;;&lt;br /&gt;print 1; print 2; print 3; # prints &amp;quot;1 2 3 &amp;quot;&lt;br /&gt;$\ = &amp;quot;,&amp;quot;;&lt;br /&gt;print 1; print 2; print 3; # prints &amp;quot;1,2,3,&amp;quot;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;I think you meant the &lt;strong&gt;$/&lt;/strong&gt; variable...&lt;/p&gt;
 </description>
     <pubDate>Thu, 19 Oct 2000 21:25:11 +0000</pubDate>
 <dc:creator>japhy</dc:creator>
 <guid isPermaLink="false">comment 1073065 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/local#comment-1073062</link>
    <description> &lt;p&gt;Nope, I mean $\ not $_&lt;/p&gt;
 </description>
     <pubDate>Thu, 19 Oct 2000 20:46:33 +0000</pubDate>
 <dc:creator>Orpheus</dc:creator>
 <guid isPermaLink="false">comment 1073062 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>perldoc perlvar</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/local#comment-1073034</link>
    <description> &lt;p&gt;There are more punctuation variables than just &lt;strong&gt;$_&lt;/strong&gt;, you know.  The &lt;strong&gt;$/&lt;/strong&gt; variable is the input record separator.  It defaults to a newline &quot;\n&quot;, but if you change it, you can change the meaning of a &quot;line&quot;.&lt;/p&gt;
&lt;p&gt;For example, if you want to read the sections of a fortune file, they&#039;re formatted like this:&lt;/p&gt;
&lt;p&gt;Funny quote here...&lt;br /&gt;
%%&lt;br /&gt;
Here&#039;s another quote that spans more than two&lt;br /&gt;
Lines, so it&#039;d be annoying to use \n as&lt;br /&gt;
the record separator, no?&lt;br /&gt;
%%&lt;br /&gt;
Etc.&lt;/p&gt;
&lt;p&gt;So that&#039;s where &lt;strong&gt;$/&lt;/strong&gt; becomes handy.  Even better, when you chomp(), you&#039;re not just removing an ending newline from a string, you&#039;re removing an ending &lt;strong&gt;$/&lt;/strong&gt; from the string.  And the variable has two special values, the empty string &quot;&quot;, and undef.  Check &lt;strong&gt;perlvar&lt;/strong&gt; for more info.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;randfortune&lt;/strong&gt;&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;#!/usr/bin/perl&lt;br /&gt; &lt;br /&gt;$/ = &amp;quot;%%\n&amp;quot;;&lt;br /&gt;open FORTUNE, shift or die &amp;quot;usage: randfortune FILE\n&amp;quot;;&lt;br /&gt;while (&amp;lt;FORTUNE&amp;gt;) {&lt;br /&gt;&amp;nbsp; if (rand($.) &amp;lt; 1) { $line = $_ }&lt;br /&gt;}&lt;br /&gt;close FORTUNE;&lt;br /&gt;chomp $line;&lt;br /&gt;print $line;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;That nifty little program reads a fortune-style file and gives you a random entry.  It uses the &lt;strong&gt;$.&lt;/strong&gt; variable too, which is the line number of the last line read from the last filehandle you read from.  It, too, is in &lt;strong&gt;perlvar&lt;/strong&gt;.  And the program uses a nice, fair algorithm&lt;br /&gt;
for choosing a random line.&lt;/p&gt;
 </description>
     <pubDate>Thu, 19 Oct 2000 11:49:42 +0000</pubDate>
 <dc:creator>japhy</dc:creator>
 <guid isPermaLink="false">comment 1073034 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/local#comment-1073029</link>
    <description> &lt;p&gt;I think he ment to say local($_), the local() means to keep whatever variables in the brackets local to the function in perl.  The $_ variable is a special variable that will give you the last result of a function or calling function.&lt;/p&gt;
&lt;p&gt;Greg&lt;/p&gt;
 </description>
     <pubDate>Thu, 19 Oct 2000 07:15:54 +0000</pubDate>
 <dc:creator>omni</dc:creator>
 <guid isPermaLink="false">comment 1073029 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
