|
From: Blackstone, J. D. <jda...@ci...> - 2002-06-05 16:20:09
|
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
|