<?xml version="1.0" encoding="windows-1252"?>
<node id="1012616" title="Re: No such file or directory error" created="2013-01-10 03:59:49" updated="2013-01-10 03:59:49">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
&lt;p&gt;&lt;i&gt; How come when I run this script ... it works just fine, but when I try using it in a bigger program it gives me the ":No such file or directory found at lingo4.pl line 508" error?&lt;/i&gt;
&lt;p&gt; Because [href://http://en.wikipedia.org/wiki/Working_directory|cwd] is cwd and and readdir doesn't return absolute paths 
&lt;p&gt; If you opendir /a/s/d/f and readdir returns . .. foo.txt, then if you try to open foo.txt, you're trying to open cwd()/foo.txt not /a/s/d/f/foo.txt, so open will fail
&lt;p&gt; you should have [id://1012220|used File::Find::Rule]
&lt;p&gt; Because your bigger program is unwieldy
&lt;p&gt; subroutine declarations are mixed with the &lt;i&gt;main&lt;/i&gt; code -- write  a single subroutine called Main, and confine the main logic of your program there -- see template at [id://45547] (and see one  discussion of that template at [id://805549]
&lt;p&gt; your code is 11 times as long as it should be -- you know how to make subroutines, so write subroutines, don't copy/paste the same code (same loops) 11 times
&lt;p&gt; You're using short and/or meaningless variable names and putting the meaning in comments -- just use meaningful variable names :)
&lt;p&gt; (sub folder) you already know how to use hashes, so don't code long if/else structures to return an integer, use a hash
&lt;p&gt; (calling folder) dozens of while loops are not a substitute for a giant if/else structure -- which you wouldn't need if sub folder teturned a string instead of an integer
&lt;p&gt; or just have sub folder take care of the printing
&lt;p&gt; and while you're at it "folder" is a terrible name for a "sub" -- call it sub processFolder
&lt;p&gt; If you have 14 minutes, watch [id://902524|String Calculator TDD Kata done in Perl] , then rewrite your code in a similar fashion
&lt;c&gt;
my %korpusEng;
sitKorpusInHash( \%korpusEng , 'korpusENG.txt' )l
...
&lt;/c&gt;
&lt;p&gt; Another example [id://997733|Out of memory and While replacements with excel XLSX application] / [href://?showspoiler=997792-10;node_id=997792|Re^2: Out of memory and While replacements with excel XLSX application]
&lt;p&gt; good luck</field>
<field name="root_node">
1012603</field>
<field name="parent_node">
1012603</field>
<field name="reputation">
11</field>
</data>
</node>
