CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
FOREACH path problem

 



Algo
New User

Aug 7, 2009, 1:54 AM

Post #1 of 4 (1174 views)
FOREACH path problem Can't Post

Hi,

I am trying to process all files in a directory, but if the path contains white_spaces then I get an error.

See code and error below:

foreach (<P:\Networks\FREE ALL\*.xml>){
print "$_\n";
};


and the error is:
Can't locate Text/ParseWords.pm in @INC.......etc etc


I've tried almost every variation but no success...

Could you help me ?

OP:xp
interpeter: tinyperl

Thanks

Algo


spider
User


Aug 7, 2009, 2:29 AM

Post #2 of 4 (1170 views)
Re: [Algo] FOREACH path problem [In reply to] Can't Post

I have never tried that syntax with:

Code
foreach(<filename>){ 
}


I allway do it something like this:


Code
open(FILE,filename) ; 
while(<FILE>){

}
close(FILE) ;


The error indecates that you need a module that is not in your @INC path. Either you don't have it installed, or you have to update your @INC path with the path to the folder containg Text.
This can be done directly in your script with a BEGIN.
Ex:

Code
BEGIN {  
push(@INC,"PATH") ;
}



KevinR
Veteran


Aug 7, 2009, 4:25 PM

Post #3 of 4 (1163 views)
Re: [Algo] FOREACH path problem [In reply to] Can't Post


Code
foreach (glob('P:/Networks/FREE ALL/*.xml')){


Note you can use forward slashes with Windows and its safer for perl to use them.

But as spider said, the error you posted has nothing to do with the line of code you posted. Text::ParseWords comes with perl so if its not in @INC it was removed for some reason. Post more of your code.
-------------------------------------------------


Algo
New User

Aug 8, 2009, 12:08 AM

Post #4 of 4 (1158 views)
Re: [KevinR] FOREACH path problem [In reply to] Can't Post

Thank you guys the answers.

I will try these things.

Algo

Ps: This is the entire code. First I'd like to clear this problem.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives