467,109 Members | 1,339 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,109 developers. It's quick & easy.

Select a file from the directories!

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
  • viewed: 1311
Share:
6 Replies
numberwhun
Expert Mod 2GB
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 2GB
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
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 2GB
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
No, It still doenst work.



Thanks,


Ravi
Jun 16 '08 #6
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.

Similar topics

4 posts views Thread by Angelos | last post: by
3 posts views Thread by Greg Yasko | last post: by
7 posts views Thread by Lowell Kirsh | last post: by
2 posts views Thread by Kenneth McDonald | last post: by
5 posts views Thread by BPearson | last post: by
9 posts views Thread by Claudio Grondi | last post: by
reply views Thread by William Gill | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.