Skip Menu |

This queue is for tickets about the Expect CPAN distribution.

Report information
The Basics
Id: 44765
Status: rejected
Priority: 0/
Queue: Expect

People
Owner: Nobody in particular
Requestors: dhester [...] yahoo-inc.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Expect bug - first pattern lost when specifying options
Date: Thu, 02 Apr 2009 16:06:07 -0400
To: bug-expect [...] rt.cpan.org
From: David Hester <dhester [...] yahoo-inc.com>
example: echo -e "\n\nfirst\nfirst\nsecond\nthird" | perl -e 'use strict;use Expect;my $exp = Expect->exp_init(\*STDIN);$exp->expect("10","-re",[qr/first/i, sub {print "found first\n";exp_continue;}], [qr/second/i, sub {print "found second\n";exp_continue;}], [qr/third/i, sub {print "found third\n";exp_continue;}]);' prints: found second found third remove the "-re" option and it finds the "first" pattern: echo -e "\n\nfirst\nfirst\nsecond\nthird" | perl -e 'use strict;use Expect;my $exp = Expect->exp_init(\*STDIN);$exp->expect("10",[qr/first/i, sub {print "found first\n";exp_continue;}], [qr/second/i, sub {print "found second\n";exp_continue;}], [qr/third/i, sub {print "found third\n";exp_continue;}]);' prints: found first found first found second found third Thanks, David Hester
From: bob [...] staats.me
I know this is old but I was going through the bugs to see what fixes I may need. I think this paticular case is probably an issue with the syntax used. I believe the position of the brackets causes the problem here. You have: Show quoted text
>> "-re",[qr/first/i, sub {print "found first\n";exp_continue;}],
If I put "-re" inside the square brackets: ["-re", qr/first/i, sub {print "found first\n";exp_continue;}], Or use no square brackets on that line: "-re", qr/first/i, sub {print "found first\n";exp_continue;}, It works OK in both cases. ############ # Option 1 # ############ echo -e "\n\nfirst\nfirst\nsecond\nthird" | perl -e 'use strict; use Expect; my $exp = Expect->exp_init(\*STDIN);$exp->expect("10", ["-re", qr/first/i, sub {print "found first\n";exp_continue;}], [qr/second/i, sub {print "found second\n";exp_continue;}], [qr/third/i, sub {print "found third\n";exp_continue;}]);' prints: found first found first found second found third ############ # Option 2 # ############ echo -e "\n\nfirst\nfirst\nsecond\nthird" | perl -e 'use strict; use Expect; my $exp = Expect->exp_init(\*STDIN);$exp->expect("10", "-re", qr/first/i, sub {print "found first\n";exp_continue;}, [qr/second/i, sub {print "found second\n";exp_continue;}], [qr/third/i, sub {print "found third\n";exp_continue;}]);' prints: found first found first found second found third
RT-Send-CC: bob [...] staats.me
Seems like a doc bug to me, no code change required. -- RGiersig@cpan.org