Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Opening files

by plaid (Chaplain)
on Jul 27, 2000 at 21:46 UTC ( #24715=note: print w/replies, xml ) Need Help??


in reply to Opening files

You have to include the path to the file, either relative to where you are, or an absolute path, unless the file is in the same current directory as you are. Your current directory is wherever you were when you ran the script, if you're running from the command line. If you're running from a webserver, your current directory is the directory where the script is. You can affect the directory with the chdir function.

For example, if you are in the directory /home/you and you want to open file.txt in the directory /home/me, you could open the file in 3 different ways:

open(FILE, "/home/me/file.txt") or die "$!"; #absolute path open(FILE, "../me/file.txt") or die "$!"; #relative path chdir("../me") or die "$!"; open(FILE, "file.txt") or die "$!"; #current dir

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://24715]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2020-06-01 00:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (177 votes). Check out past polls.

    Notices?