我有这个结构
package StrukturaStudent;
use Class::Struct;
struct Student => {
sifra => '$',
ime => '$',
prezime => '$',
brojBodova => '$'
};
和功能
sub ispisiStudenta($st){
print $st->{sifra}." ". $st->{ime}." ". $st->{rezime}." ". $st->{brojBodova}."\n";
}
我想在其中打印当前学生。
In another package I have an array of students and call this function as
StrukturaStudent->ispisiStudenta(@lista[1])."\n";
I don't get anything (only new empty line on console). But when I call this from main
print @lista[1]->ime;
I got right what I need. So how to pass a single student from the array and print it inside function? Moreover, how can I pass the whole array and print every student in it inside a for loop?