rockyb has asked for the wisdom of the Perl Monks concerning the following question:
I came across code like this in trying to work out a bug in Term::ReadLine::Perl5.
#!/usr/bin/perl use strict; use Term::ReadLine; my $term = Term::ReadLine::Stub->new('test'); # $term is a blessed array reference print $term, ' ', $term->OUT, "\n"; # output is: Term::ReadLine::Stub=ARRAY(0x9d73a7c) GLOB(0x9da48a8)
My question is how does $x->OUT seem to get to be the same thing as $x->[1] (if I have this right and I might not).
I find this confusing, do others as well? If so, given that for compatibility there the object is an array references, is there a less confusing way to write this. Or is this way preferable, given that's how it is in the documentation?
I should say that I think although Perl allows you to bless an array reference, I think it is a mistake in Term::Readline::Stub to do so.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How does this tricky Perl code in Term::ShellUI using Term::ReadLine dereference an Array?
by rockyb (Scribe) on Jun 19, 2015 at 14:04 UTC |