Solved

ActiveState Perl for Win32

Posted on 1998-11-02
2
213 Views
Last Modified: 2010-03-04
Hi,
Do I have to always give the full path when I refer to an other file within my script.

If no, How?
0
Comment
Question by:martalex
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 50 total points
ID: 1205874
No, you don't.  You can use relative paths in the same way that you would in any operation.  However, if you use a relative path, you need to know what it's relative to (the current working directory), and what that might be.

If you're talking about use'ing or require'ing files, the current include path (@INC) is used.
0
 
LVL 1

Expert Comment

by:johnsm
ID: 1205875
I've found that if the file is in the same directory as the script you can use

   open (FH, "file.txt");

but if it is not then you need to use

   open (FH, "c:\whatever\file.txt");

even if c:\whatever is in your path.

I found that even though my datafile is in a directory that is in my path, if my script is not in the same directory perl will not find it.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question