I know I could use a link to the file like "../info.txt" but it doesn't open the file, unless the path is absolute to the file.
Where did you get that idea? Of course you can use . and .. directories in a path to a file for opening.
Since you don't state where the files' directory is relative to the cgi-bin directory, it is difficult to give very precise advice. However, in general, use ../ to go up one level in the directory hierarchy and the exact directory name to go down.
Say you have a directory structure like this:
|--apache2--|---cgi-bin
|
|---htdocs
|
|---images
or whatever. To access a file from the htdocs directory, starting at the cgi-bin directory, you would specify: '../htdocs/info.txt'. Substituted back into your script:
use warnings; use strict; $0 =~ '(.*[\\\/])\w+\.\w+$'; my $curr_dir = $1 || "./"; # Note, you would be much better off with # use Cwd; # and # my $curr_dir = cwd(); $info_file = $curr_dir . '../htdocs/info.txt'; open my $fh, '<', $info_file or die "Could not open file, $!"; while (my $line = <$fh>){ #process line }
In reply to Re: File Open Issue
by thundergnat
in thread File Open Issue
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |