Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

[SOLVED] How does this tricky Perl code in Term::ShellUI using Term::ReadLine dereference an Array?

by rockyb (Scribe)
on Jun 19, 2015 at 13:58 UTC ( [id://1131139]=perlquestion: print w/replies, xml ) Need Help??

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.

  • Comment on [SOLVED] How does this tricky Perl code in Term::ShellUI using Term::ReadLine dereference an Array?
  • Select or Download Code

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
    Sorry for the noise, but it was mentioned in StackExchange that OUT is a method. So that mystery has been solved and I've deleted this on StackExchange.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1131139]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found