Name: Anonymous 2010-11-08 17:33
I am creating a PERL program to do some stuff with the British National Corpus.
I cannot use XML::Simple (for example), because the admin will not install packages for me, and not grant me enough rights to install it myself through CPAN.
The problem I face now is that I have two structs:
struct Token =>
{
c5Type => '$',
lemma => '$',
word => '$',
};
struct Sentence =>
{
number => '$',
tokens => '@',
};
And an array:
my @sentences = ();
and is filled with sentences and sentences are filled with tokens, according to the output of Data::Dumper:
$VAR1 = [
bless( {
'Token::c5Type' => 'NP0-NN1',
'Token::lemma' => 'ba',
'Token::word' => 'BA'
}, 'Token' ),
...
But when I try to print such output myself, I keep getting the error that "word" is an unblessed reference. And I cannot figure out a way to solve it.
The code in which I use it:
foreach my $sentence (@sentences)
{
print $sentence->number."\n"; # gets printed
foreach my $token ($sentence->tokens)
{
print $token->word;
# print Dumper($token)."\n";
}
}
I really have no clue as to what to do, I tried everything from dereferencing (in all sorts of ways) to manually trying to print, but to no avail. Anyone got some tips?
I cannot use XML::Simple (for example), because the admin will not install packages for me, and not grant me enough rights to install it myself through CPAN.
The problem I face now is that I have two structs:
struct Token =>
{
c5Type => '$',
lemma => '$',
word => '$',
};
struct Sentence =>
{
number => '$',
tokens => '@',
};
And an array:
my @sentences = ();
and is filled with sentences and sentences are filled with tokens, according to the output of Data::Dumper:
$VAR1 = [
bless( {
'Token::c5Type' => 'NP0-NN1',
'Token::lemma' => 'ba',
'Token::word' => 'BA'
}, 'Token' ),
...
But when I try to print such output myself, I keep getting the error that "word" is an unblessed reference. And I cannot figure out a way to solve it.
The code in which I use it:
foreach my $sentence (@sentences)
{
print $sentence->number."\n"; # gets printed
foreach my $token ($sentence->tokens)
{
print $token->word;
# print Dumper($token)."\n";
}
}
I really have no clue as to what to do, I tried everything from dereferencing (in all sorts of ways) to manually trying to print, but to no avail. Anyone got some tips?