Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

perl beginner question

by Anonymous Monk
on May 24, 2009 at 08:54 UTC ( #765900=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I got error No such file or directory at xxx.pl at line 58 even if i got the directory there.. the directory name given is C:\\temp and also tested with C:/temp etc... and the directory is not in open when i was testing can anyone suggest a fix to this problem

Replies are listed 'Best First'.
Re: perl beginner question
by marto (Cardinal) on May 24, 2009 at 09:49 UTC

    Perhaps the remove_tree function from the File::Path module (it's a core module) would be of interest here.

    Martin

Re: perl beginner question
by Anonymous Monk on May 24, 2009 at 09:02 UTC
    show your code
      sub removedir { my $dir= shift; opendir DIR, $dir or die "opendir $dir: $!"; for (readdir DIR) { next if /^\.{1,2}$/; my $path = "$dir/$_"; #check $path is a file? if(-f $path) { print "file: $path\n"; } } }
        And which one is "line 58"?

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: perl beginner question
by lamprecht (Friar) on May 24, 2009 at 14:54 UTC
    You will get the best help if you post a stripped down runnable example that demonstrates your problem. Most of the time you will see, that while composing such an example you find the bug yourself and don't need to post it...

    Cheers, Christoph

      Good advice/observation. Reminds me remotely of Did you talk to the bear? - found here: brian's Guide to Solving Any Perl Problem.

      Did you talk to the bear?

      Explain your problem aloud. Actually say the words.

      For a couple of years I had the pleasure of working with a really good programmer who could solve almost anything. When I got really stuck I would walk over to his desk and start to explain my problem. Usually I didn't make it past the third sentence without saying ``Never mind---I got it''. He almost never missed either.

      Since you will probably need to do this so much, I recommend some sort of plush toy to act as your Perl therapist so you do not annoy your colleagues. I have a small bear that sits on my desk and I explain problems to him. My wife does not even pay attention when I talk to myself anymore.

      Hi Christoph, Thanks for the input.try to post like what you suggested on next time...
Re: perl beginner question
by bradcathey (Prior) on May 24, 2009 at 12:18 UTC

    You have a path or permissions problem, no doubt.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: perl beginner question
by Anonymous Monk on May 24, 2009 at 14:53 UTC
    thanks guys.. i fixed the problem, it is due to the \n at the end of the directory name which is read from a file,i fixed that with a trim function

      Are you using chomp?

      Martin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://765900]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2020-10-28 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (260 votes). Check out past polls.

    Notices?