Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

How do I specify the drive/path when writing a file?

by Anonymous Monk
on Jul 25, 2000 at 21:31 UTC ( [id://24305]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that creates a data file. I would like to be able to save it on their c drive if possible.....

..is that possible?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I specify the drive/path when writing a file?
by Shendal (Hermit) on Jul 25, 2000 at 21:41 UTC
    Just specify the drive/path when you're creating the data file. For example:
    open(FILE,">c:/temp/file.txt") or die "Unable to open file.txt for wri +ting: $!"; print FILE "woohoo!\n"; close(FILE);
    Hope that helps,
    Shendal
Re: How do I specify the drive/path when writing a file?
by wardk (Deacon) on Aug 22, 2000 at 01:29 UTC

    Not specifically relevent, but something that I needed to keep in mind...

    In a Windows-centric network environment, you can utilize UNC drive mappings if running across the network. (you should use UNC's whenever possible, users can change drive letter mappings at will!)

    I.E. If desiring to write to a network resource, try to avoid "drive letter" mappings like

    x:\somedirecotryonaserver\subdir\filename <code> <p> and use: </p> <code> \\server\sharename\subdir\filename

    In perl, be sure to escape all the slashes, and if your admins use the dollar sign$ for shares, be sure to escape that too!

    ala

    open FH, ">\\\\server\\sharename\$\\subdir\\filename" or die "cannot o +pen file: $!";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found