469,330 Members | 1,346 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Opening a Windows file

Easy one for all you Perl gurus out there.

I'm opening a text file, reading the contents into an array, doing some processing and spitting out the results to another file. Although I've got this working fine, I had to employ a workaround when opening the file originally.

I wanted to put:
open(INPUT, "d:\pscripts\input.txt")
or die "Could not open file for reading $!\n";

but when I executed this, it kept dying on me, saying that it couldn't find the file. Eventually, I had to put my input file in the same directory as the script (my workaround) and remove the path from the "open" command above.

It works, but it's bugging me. Why wouldn't it work with the full path?

TIA
Oct 10 '06 #1
4 18271
S'OK - figured it out. The slashes in the Windows path name have to go the other way.

But of course.... ??????
Oct 10 '06 #2
S'OK - figured it out. The slashes in the Windows path name have to go the other way.

But of course.... ??????

because perl on windows follows the unix like paths.

infact in internally trnsalate every path according to unix file system
Oct 10 '06 #3
miller
1,089 Expert 1GB
Your previous code would have worked too, but you needed to escape the backslashes:

Expand|Select|Wrap|Line Numbers
  1. open(INPUT, "d:\\pscripts\\input.txt")
  2. or die "Could not open file for reading $!\n";
  3.  
or used single quotes so that the string was not interpolated:

Expand|Select|Wrap|Line Numbers
  1. open(INPUT, 'd:\pscripts\input.txt')
  2. or die "Could not open file for reading $!\n";
  3.  
Oct 16 '06 #4
nmadpl
5
Hi,
I am trying to do a similar thing.
Can you help me sharing your code?

Thanks
Nov 16 '06 #5

Post your reply

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

Similar topics

2 posts views Thread by EP | last post: by
5 posts views Thread by albo | last post: by
14 posts views Thread by W Marsh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.