|
From: Blackstone, J. D. <jda...@ci...> - 2002-06-05 16:29:10
|
And it looks like the solution is to change line 824 of Expect.pm 1.15
which says
if ($#{$eof_pat} > 3) {
to instead say
if (defined $eof_pat->[3]) {
I believe $eof_pat->[3] is the coderef to call. It is inserted into the
$eof_pat array by line 504 I think which tries to shift it off of a
parameter list. Unfortunately if there was no coderef specified this
inserts an undef into the array. The array is then the right size, but has
an undefined value instead of a subroutine reference there. So, if we test
for the definedness of the subroutine reference, we'll know whether or not
we should attempt to call it.
Of course, I may be completely wrong!!! :)
jdb
> -----Original Message-----
> From: Blackstone, J. David [mailto:jda...@ci...]
> Sent: Wednesday, June 05, 2002 11:20 AM
> To: exp...@li...
> Subject: [Expectperl-discuss] eof treated too specially :)
>
>
> If I try to
>
> $exp->expect($t, ["password"]);
>
> it works just fine, but if I try to
>
> $exp->expect($t, ['eof']);
>
> I have problems because it wants me to supply a coderef to
> call. So I get
> an error message which says "Can't use string ("") as a
> subroutine ref while
> "strict refs" in use at
> /usr/local/perl561/lib/site_perl/5.6.1/Expect.pm
> line 829." I have to
>
> $exp->expect($t, ['eof' => sub { }]);
>
>
> In a related issue, it seems you have to use the arrayref
> syntax to get
> the special eof treatment. You can't
>
> $exp->expect($t, 'eof')
>
> or you'll be matching the literal string 'eof.'
>
>
> It's too bad we can't create a special magical regex+
> object that could
> stand for a regular expression or a literal string or a
> special condition
> like eof. I'm sure that would greatly simplify the Expect.pm code. :)
> Hmmm... this gives me something else to lie awake thinking
> about at night.
>
> BTW, I think expecting eof is going to shape up to be an
> answer to some
> FAQs in the future. If you're interested, all of this
> originated in a use
> Perl; thread at http://use.perl.org/~djberg96/journal/5430 .
>
> jdb
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
> _______________________________________________
> Expectperl-discuss mailing list
> Exp...@li...
> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss
>
|