I know that file names can be variable in perl scripting.Does the same apply to cgi-perl scripting.Because when I used variables inside open statement I get the error No such file or directory.But when I directly mention the path the file is opened for reading.These variables are passed from a form. The values are passed correctly they are not empty(Checked by printing the varaiables).
open (FILE, '/var/www/cgi-bin/$dir/$file')
or print "file cannot be opened $!\n";
file cannot be opened no such file or directory
Use double quotes to interpolate variables:
open (FILE, "/var/www/cgi-bin/$dir/$file") # here __^ and here __^ or print "file cannot be opened $!\n";
use strict; use warnings;
By using single quotes, the varibles aren'tt interpolated, so you're trying to open literally
/var/www/cgi-bin/$dir/$file and it doesn't exist.