Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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 line 508" error?

Because cwd is cwd and and readdir doesn't return absolute paths

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

you should have used File::Find::Rule

Because your bigger program is unwieldy

subroutine declarations are mixed with the main code -- write a single subroutine called Main, and confine the main logic of your program there -- see template at (tye)Re: Stupid question (and see one discussion of that template at Re^2: RFC: Creating unicursal stars

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

You're using short and/or meaningless variable names and putting the meaning in comments -- just use meaningful variable names :)

(sub folder) you already know how to use hashes, so don't code long if/else structures to return an integer, use a hash

(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

or just have sub folder take care of the printing

and while you're at it "folder" is a terrible name for a "sub" -- call it sub processFolder

If you have 14 minutes, watch String Calculator TDD Kata done in Perl , then rewrite your code in a similar fashion

my %korpusEng; sitKorpusInHash( \%korpusEng , 'korpusENG.txt' )l ...

Another example Out of memory and While replacements with excel XLSX application / Re^2: Out of memory and While replacements with excel XLSX application

good luck

In reply to Re: No such file or directory error by Anonymous Monk
in thread No such file or directory error by Dr Manhattan

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (5)
    As of 2015-11-30 05:55 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (758 votes), past polls