473,663 Members | 2,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a Windows file

2 New Member
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\in put.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 18533
slawson7
2 New Member
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
deep022in
23 New Member
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 Recognized Expert Top Contributor
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 New Member
Hi,
I am trying to do a similar thing.
Can you help me sharing your code?

Thanks
Nov 16 '06 #5

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

Similar topics

3
4394
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 file and then click on Properites, then the Summary tab. I want to be able to modify the Subject line and the Comments line in particular. I'm hoping someone can tell me how to do this. Thanks, lq
2
4487
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 Thanks in advance Yogi
2
8790
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 really do not understand Windows file system - e.g. is properties metadata attached to the file? if I change that metadata do I change the file's hash? how is the metadata structured? or is the "properties" metadata simply derived upon access? ...
18
6709
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 I've already created on my computer. Whenever I go to open the script file (whose icon shows that it's a SQL Server Query File and I've got the file type set to open with SQLWB - SQL Server Management Studio), the file opens in Notepad instead of...
8
2127
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- f = file('veryBigFile.dat','r+') IOError: No such file or directory: 'veryBigFile.dat'
5
1571
by: albo | last post by:
hi all !! i need help in opening an image file (bmp) and printing it to the screen. thanks
14
1762
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 ended) to read the file, I find that the data I have written doesn't exist in there. I can't read it back until I run the script again. My question follows: WHAT
3
6791
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 calculations. when opening this file with vb 6.0 code it works fine. here is a the simple code: Dim xlObject, xlBook,wks
1
1820
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 self as another window. There is no problem in opening this file if the file is small. If the file is big(here i mean to say if number of tables present in this file)then while opening this file my application is displaying a message "Cannot create...
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.