Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by Anonymous Monk
on Jul 25, 2000 at 21:31 UTC ( #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.

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

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
Node Status?
node history
Node Type: perlquestion [id://24305]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2021-04-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?