<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1012691" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1012691</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Style Points</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073412</link>
    <description> &lt;p&gt;Continue style discussion at the newly created post.&lt;/p&gt;
 </description>
     <pubDate>Wed, 01 Nov 2000 02:50:02 +0000</pubDate>
 <dc:creator>japhy</dc:creator>
 <guid isPermaLink="false">comment 1073412 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073409</link>
    <description> &lt;p&gt;Vorm, I believe that Larry Wall, Perl&#039;s creator requested that it be written as Perl, rather than PERL.&lt;/p&gt;
 </description>
     <pubDate>Wed, 01 Nov 2000 01:29:35 +0000</pubDate>
 <dc:creator>Rob Pengelly</dc:creator>
 <guid isPermaLink="false">comment 1073409 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073408</link>
    <description> &lt;p&gt;Well, actually, I&#039;m pretty sure PERL is an acronym, and acronyms are capitalized, so...&lt;/p&gt;
&lt;p&gt;Yeah, the split thing was different. Ditto for the no () around the push.&lt;/p&gt;
 </description>
     <pubDate>Wed, 01 Nov 2000 01:21:17 +0000</pubDate>
 <dc:creator>Vorm</dc:creator>
 <guid isPermaLink="false">comment 1073408 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Why use arrays, anyway?</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073407</link>
    <description> &lt;p&gt;Anyway, there probably is no need to store all the lines of the file into an array, and then iterate over the array.  That takes up memory needlessly.  Use a while loop.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;open FILE, $filename or die &amp;quot;can&amp;#039;t read $filename: $!&amp;quot;;&lt;br /&gt;while (&amp;lt;FILE&amp;gt;) {&lt;br /&gt;&amp;nbsp; # do something with $_&lt;br /&gt;}&lt;br /&gt;close FILE;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
 </description>
     <pubDate>Wed, 01 Nov 2000 01:19:33 +0000</pubDate>
 <dc:creator>japhy</dc:creator>
 <guid isPermaLink="false">comment 1073407 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073406</link>
    <description> &lt;p&gt;So is your spelling of &quot;Perl&quot;, Vorm.&lt;/p&gt;
&lt;p&gt;What strikes you as odd about my Perl code?  The fact that I didn&#039;t send any arguments to split()?  The fact that I used the default &lt;strong&gt;$_&lt;/strong&gt; variable in my for loops?&lt;/p&gt;
&lt;p&gt;Err, the fact that I called push incorrectly... that should have been&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;for (@lines) {&lt;br /&gt;&amp;nbsp; my @words = split;&lt;br /&gt;&amp;nbsp; push @list_of_words, \@words;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;There.  Less odd-looking now?&lt;/p&gt;
 </description>
     <pubDate>Wed, 01 Nov 2000 01:15:08 +0000</pubDate>
 <dc:creator>japhy</dc:creator>
 <guid isPermaLink="false">comment 1073406 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073405</link>
    <description> &lt;p&gt;Your PERL is weird looking japhy.&lt;/p&gt;
&lt;p&gt;Anyways, I&#039;d just do the processes for each array without creating one for each file.&lt;/p&gt;
 </description>
     <pubDate>Wed, 01 Nov 2000 00:59:54 +0000</pubDate>
 <dc:creator>Vorm</dc:creator>
 <guid isPermaLink="false">comment 1073405 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Soft References are BAD!</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073404</link>
    <description> &lt;p&gt;That&#039;s because &lt;strong&gt;$foo$bar = &quot;something&quot;&lt;/strong&gt; is not valid syntax in Perl.  What you&#039;re trying to do is:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;@{&amp;quot;articles$i&amp;quot;} = (...);&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;That&#039;s called a &quot;soft reference&quot;.  DO NOT USE THEM.  They have one very specific use in Perl, and that is the only time they should be used.  Specifically, their use is NOT in this case.  You should probably be using an array of references to arrays:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;for (@lines) {&lt;br /&gt;&amp;nbsp; my @words = split;&lt;br /&gt;&amp;nbsp; # push @list_of_words = \@words; # &amp;lt;-- ERROR&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Now &lt;strong&gt;@list_of_words&lt;/strong&gt; is an array, each of whose elements are references to an array.  To access the data, you&#039;d do something like:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;for (@list_of_words) {&lt;br /&gt;&amp;nbsp; my @data = @$_;&amp;nbsp; # @{ ... } dereferences an array ref&lt;br /&gt;&amp;nbsp; # ...&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;For more information on references, read the &lt;strong&gt;perlreftut&lt;/strong&gt;, &lt;strong&gt;perlref&lt;/strong&gt;, &lt;strong&gt;perldsc&lt;/strong&gt;, and &lt;strong&gt;perllol&lt;/strong&gt; documentation (available on your computer or at &lt;a href=&quot;http://www.perldoc.com/&quot; class=&quot;bb-url&quot;&gt;http://www.perldoc.com/&lt;/a&gt;.  I also have a small document on using references on my web site at &lt;a href=&quot;http://www.pobox.com/~japhy/&quot; class=&quot;bb-url&quot;&gt;http://www.pobox.com/~japhy/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; check my next post for the correction of that code.  Silly japhy...&lt;/p&gt;
&lt;p&gt;[Edited by japhy on 10-31-2000 at 08:16 PM]&lt;/p&gt;
 </description>
     <pubDate>Tue, 31 Oct 2000 21:47:47 +0000</pubDate>
 <dc:creator>japhy</dc:creator>
 <guid isPermaLink="false">comment 1073404 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073399</link>
    <description> &lt;p&gt;well, i have that, but i get a syntax-error...&lt;br /&gt;
here&#039;s my code:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;$i = &amp;quot;1&amp;quot;;&lt;br /&gt;foreach $line (@articleslist) {&lt;br /&gt;	open(ARTICLE, &amp;quot;$stuffdirectory/$line&amp;quot;) || die &amp;quot;No such file: $line&amp;quot;;&lt;br /&gt;		@articles$i = &amp;lt;ARTICLE&amp;gt;;&lt;br /&gt;	close(ARTICLE);&lt;br /&gt;	++$i;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;br /&gt;
the error is in line 5 (@articles$i = &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Tue, 31 Oct 2000 07:08:52 +0000</pubDate>
 <dc:creator>merlin</dc:creator>
 <guid isPermaLink="false">comment 1073399 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073396</link>
    <description> &lt;p&gt;Vorm-&lt;br /&gt;
you forgot one little thing.  in your second one (I&#039;m assuming you copied and pasted from the first) you forgot the $i at the end of @articles&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;$i=&amp;quot;1&amp;quot;;&lt;br /&gt;foreach $line (@articleslist) {&lt;br /&gt;open(HEH, &amp;quot;&amp;lt;$line&amp;quot;);&lt;br /&gt;@articles$i=&amp;lt;HEH&amp;gt;;&lt;br /&gt;close(HEH);&lt;br /&gt;&lt;br /&gt;print @articles$i;&lt;br /&gt;&lt;br /&gt;++$i;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
 </description>
     <pubDate>Tue, 31 Oct 2000 06:48:11 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1073396 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/filehandle#comment-1073394</link>
    <description> &lt;p&gt;thanks vorm, you just gave me a nice idea... i think i&#039;ll go for two... but still i&#039;ll try one too (just for fun)... &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Tue, 31 Oct 2000 06:39:19 +0000</pubDate>
 <dc:creator>merlin</dc:creator>
 <guid isPermaLink="false">comment 1073394 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
