473,231 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

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?

Oct 10 '06 #1
4 18497
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
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";
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";
Oct 16 '06 #4
I am trying to do a similar thing.
Can you help me sharing your code?

Nov 16 '06 #5

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

Similar topics

by: Lauren Quantrell | last post by:
I'd like to use my Access 2K application to write some text in the file properties of a Windows file. The properties I'm talking about are the properties you see whn you right click on a Windows...
by: muttu2244 | last post by:
hi all could anybody please tell me how can i copy a file from windows file systems like FAT12, FAT16,FAT32 and NTFS to EXT2, and EXT3. Is their any function in python that we can do the above ...
by: EP | last post by:
I'm looking for a method by which to access Windows files metadata and have not been able to find anything in the standard modules or via Google - what is the standard approach? Shamefully I...
by: mollyf | last post by:
I just installed SQL Server 2005 on my PC (the developer's edition) yesterday. I have some scripts written by one of my coworkers to create some tables and stored procedures in a database that...
by: Claudio Grondi | last post by:
Here an example of what I mean (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte large file): Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel-...
by: albo | last post by:
hi all !! i need help in opening an image file (bmp) and printing it to the screen. thanks
by: W Marsh | last post by:
Hi. In my application I do something very simple - I open a file, lock it exclusively, write some data to it and close it. If I re-open it in the same process (I mean before the script has...
by: blerina | last post by:
hi, i have a simple asp code that opens an excel file. it works fine with simple excel files that don't contain formula. i think the problem is that my excel file contains formulas and...
by: Sanjeeva K kanakam | last post by:
Hi all, I am developing one application. In that i have created on report file which contains tables, titles and tree view list also by using HTML tags. I am opening this file in my application it...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.