Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Unblessed reference in Perl

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?

Name: Anonymous 2010-11-08 17:43

Install the packages you need locally.

Go here: http://www.perlmonks.org/index.pl?node_id=128077
Scroll down to where it says: "I don't have permission to install a module on the system!"

Now go re-write that shit using the proper perlmods instead of trying to re-invent the wheel.


Furthermore, don't post again until:
1 - you stop being such a clueless llama.
2 - you Google for the answers to your questions first.

Name: Anonymous 2010-11-08 17:54

I'll try that.
Didn't really occur to me to try to install it another way.

For future reference, if someone as clueless as me gets the same problem, make it: foreach my $token (@{$sentence->tokens}).

But now that I have it working, I'll go do it properly. TY

Name: Anonymous 2011-02-03 0:16

Name: Anonymous 2011-02-03 5:47

Name: Anonymous 2011-02-03 7:38


Don't change these.
Name: Email:
Entire Thread Thread List