By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,933 Members | 1,675 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,933 IT Pros & Developers. It's quick & easy.

Select a file from the directories!

P: 68
Hi,


I want to perform a certain set of operations on a text file which is available on my computer.
I wanted to know how to select a file from these directories on my computer.


Any help is appreciated.


Thank you,


Ravi
Jun 3 '08 #1
Share this Question
Share on Google+
6 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Hi,


I want to perform a certain set of operations on a text file which is available on my computer.
I wanted to know how to select a file from these directories on my computer.


Any help is appreciated.


Thank you,


Ravi
What have you tried thus far to select the file? What OS are you working on?

Regards,

Jeff
Jun 3 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
Hi,


I want to perform a certain set of operations on a text file which is available on my computer.
I wanted to know how to select a file from these directories on my computer.


Any help is appreciated.


Thank you,


Ravi
Expand|Select|Wrap|Line Numbers
  1. open(FH, 'path/to/file.txt') or die "$!";
  2. while(<FH>) {
  3.    perform a certain set of operations
  4. }
  5. close FH;
Jun 3 '08 #3

P: 68
Expand|Select|Wrap|Line Numbers
  1. open(FH, 'path/to/file.txt') or die "$!";
  2. while(<FH>) {
  3.    perform a certain set of operations
  4. }
  5. close FH;


Hi,


I tried the following thing :

Expand|Select|Wrap|Line Numbers
  1. open (OUT, $filename) || die "Can't open the File $!\n";
  2.  
  3. while(<OUT>)
  4. {
  5.     print "$_";
  6. }
  7. close(OUT);
  8.  
  9.  

the value of file name is "H:\cgi\cgi\cgi\Klocwork\clearquest.txt".
this doesnt open the file. and Displays :

Software error:
Can't open the File No such file or directory


This happens, when i open the file irrespective of the directory where the source code is stored or not.

Can anyone tell why this problem is occuring?


Thank You,


Ravi
Jun 11 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
even if you are on windows, try using forward slashes in the directory path:

Expand|Select|Wrap|Line Numbers
  1. $filename = 'H:/cgi/cgi/cgi/Klocwork/clearquest.txt';
if you still get a software error I don't know what the problem could be.
Jun 12 '08 #5

P: 68
No, It still doenst work.



Thanks,


Ravi
Jun 16 '08 #6

P: 68
Hi,


Well, i realized y the file was not opening...
actually, my perl script runs on the server side. and the path im giving, is mapped to a network drive.
So, The H:/ drive is actually a network drive, and not on my Local hard disk.

This mapping Perl script doesnt recognize and hence it can't open this file.


I have looked for an option. Save the file in my soruce code directory, and open tat file just by th efile name instead of giving the whole the path.


Is there any alternative to do the similar function of opening a txt file on the local database and doing some operation on tat txt file using the perl scipt which is run on a distant server.


Any help is appreciated.


Thanks,


Ravi
Jun 16 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.