I'm relatively new to manipulating files in Perl. I don't know what's wrong with this code that it does not write anything to my text file. I don't think it's with my data structure because I have another function which prints the contents of the data structure and the data is there. It just doesn't get written in the file. Am I missing something?
Here is the code :
sub saveFile {
open( my $out, ">", "inputs.txt" );
for ( $i = 0; $i < $#students; $i++ ) {
print $out $students[$i]->{"name"};
print $out $students[$i]->{"studNum"};
print $out $students[$i]->{"cNum"};
print $out $students[$i]->{"emailAdd"};
print $out $students[$i]->{"gwa"};
print $out $students[$i]->{"subjNum"};
for ( $j = 0; $j < $students[$i]->{"subjNum"}; $j++ ) {
print $out $students[$i]->{"subj"}->[$j]->{"courseNum"};
print $out $students[$i]->{"subj"}->[$j]->{"courseUnt"};
print $out $students[$i]->{"subj"}->[$j]->{"courseGrd"};
}
}
close $out;
print "FILE SAVED.\n";
}