jasondancks has asked for the wisdom of the Perl Monks concerning the following question:
To try to eliminate potential issues, the following was ran from the command line:
test script:CreateExam.pm:#!/usr/bin/perl use CGI qw(:standard); use CGI qw(:standard Vars); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use File::Basename; use lib dirname(__FILE__); use CreateExam; my $cgi = CGI->new(\*STDIN); print $cgi->header(); print $cgi->start_html("test"); my $check = CreateExam->new("/var/www/roger/homeworks/hw13/exam4.txt", +"/var/www/roger/homeworks/hw13/answers4.txt","/var/www/roger/homework +s/hw13/grades4.txt",0); my %ans; $ans{"1"} = "0AD"; $ans{"2"} = "Johnny Manziel"; $ans{"3"} = "washington"; $ans{"4"} = "Shes so hiiiigggghhhhhh\nHigh above me\nShes so hiiiigggg +hhhhhh above me\nCleopatra Joan of Arc Aphrooooodiiiiitttteeee\n"; print $check->entergrades("test",\%ans); print qq(<div style="margin:10px;border:solid;border-width:10px;border +-color:#FFFFFF">\n); $check->printgrades("test"); print "</div>\n"; print $cgi->end_html();
output:sub new { my ($class,$file,$answers,$grades,$script) = @_; #print "<p>in new: file: $file, grades: $grades</p>\n"; return bless {'file'=>$file,'answers'=>$answers,'gradefile'=>$grad +es,'script'=>$script},$class; } .... sub entergrades { my ($self,$person,$answers) = @_; my $afile = $self->{'answers'}; open(ANSWERS,"<$afile") or die "$afile: $!"; my $grades = $self->{'gradefile'}; open(GRADES,"<<$grades") or die "got error $! (".($!+0).")\n"; # p +roblem right here ... }
double check file exists:Software error: got error No such file or directory (2)
jddancks@debian-macbook:/var/www/roger/homeworks/hw13$ ls -l /var/www/ +roger/homeworks/hw13/grades4.txt -rwxr-xr-x 1 jddancks jddancks 2095 Jan 16 16:30 /var/www/roger/homewo +rks/hw13/grades4.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl CGI: No such file or directory yet file exists???
by fishmonger (Chaplain) on Jan 17, 2015 at 19:51 UTC | |
|
Re: perl CGI: No such file or directory yet file exists???
by graff (Chancellor) on Jan 17, 2015 at 20:38 UTC | |
|
Re: perl CGI: No such file or directory yet file exists???
by NetWallah (Canon) on Jan 18, 2015 at 01:38 UTC |