?
Solved

Simple for Points!  Saving in another directory....

Posted on 2003-03-26
4
Medium Priority
?
168 Views
Last Modified: 2010-03-05
Here's the scoop:

# ***** I create new file *****
open (NEW_FILE, ">myfile.csv") || die "Can't find database\n";
close (NEW_FILE);

# ***** I write in new data *****
open (FILE2,">>myfile.csv") || die "Can't find database\n";
print FILE2 "$affiliate,$fullname,$email,$date\n";
close (FILE2);

This saves file into the cgi-bin directory, how do I save in another directory?
current for create/save: http://www.mydomain.com/cgi-bin/myfile.csv
want for create/save: http://www.mydomain.com/files/myfile.csv
0
Comment
Question by:precision
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Expert Comment

by:tosch
ID: 8211211
open(FILE,">../files/myfile.csv") || die "unable to open myfile.csv for writing, stopped";

or give a an absolute path:
open(FILE,">home/www/www.mydomain.com/web/files/myfile.csv") || die "unable to open myfile.csv for writing, stopped";

can be the structure of the URL does not map 1:1 to the file system on your server machine (if apache is configured using directory aliases for example).

in case you have a structure like

$HOME/cgi-bin
$HOME/html

http://www.mydomain.com/somefile.html mapping to $HOME/html/somefile.html

and

http://www.mydomain.com/cgi-bin/somescript.pl mapping to $HOME/html/somescript.html

you will have to use ../html/files.myfile.csv in the first example.
0
 
LVL 3

Accepted Solution

by:
tosch earned 500 total points
ID: 8211221
ooops.
there`s a slash missing in the second example:

open(FILE,">home/www/...

must be

open(FILE,">/home/www/...
0
 

Author Comment

by:precision
ID: 8211879
Also...two more quick questions...

1)  clicking on myfile.csv opens the file in the browser, how can I force to have the client the option of "save" or "open"?

2)  Before I write data to file, I want to be sure that no characters are "," to avoid corrupting the database file, script for within perl.

Thanks...G
0
 
LVL 3

Expert Comment

by:tosch
ID: 8219809
1)

i'm not to sure if you can at all ( this means i don't know if the browser reacts to the Content-type send in the http header or to the extension "csv" - in the first case you might be able to reconfigure the mime types on your web server - in the second case you simply can't)

2)

what do you want to do with the ',' - character ?
delete them ? escape/replace them ?

search-replace is done like this in perl:

$a="foo bar baz foo bar baz foo bar baz";
$a=~ s/bar/bah/g;

# $a is now "foo bah baz foo bah baz foo bah baz"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
Six Sigma Control Plans

752 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