Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

expect module: exp_continue error

by chime (Friar)
on Jul 13, 2004 at 11:03 UTC ( [id://373916]=perlquestion: print w/replies, xml ) Need Help??

chime has asked for the wisdom of the Perl Monks concerning the following question:

I have oogled and googled but I can't spot why I am getting an error when I run this program

use Expect; # use strict; # commented out to allow program to run for now # Spawn program using perl expect module my $exp = Expect->spawn($run_program) or die "Cannot spawn $run_program: $!\n"; # Turn off output of results from stdout $exp->log_stdout(1); # Wait for runrep to initialise $exp->expect(600,[ qr/Read in all files/]); $exp->send("runprogram $report_name $output_format \n"); # Wait for report to run or generate an error $exp->expect(600, [ qr/Error/i, sub { my $self = shift; $self->send("quit\n"); print ("program.pl has an error: $_ \n"); exp_continue; }], # *** [ qr/Report run successful./i, sub { my $self = shift; $self->send("quit\n"); exp_continue; }]);} # ***

I get the following error:

Bareword "exp_continue" not allowed while "strict subs" in use at perlscript.pl line 418.
(which is marked with ***)
Which is the -- exp_continue; }], -- line

When I take out the first sub part the error just appears in the next line containing exp_continue # ***

The print function doesn't have any effect on curing this error.

The code works when I comment out the use strict line, but this is bad and I would prefer to fix this error and keep using use strict.

My question is can any one spot any errors that might cause the code to give out the error. Is it obvious.?
Or can any one suggest a better use of the
# Wait for report to run or generate an error
part of the expect module

When I use diagnostics I get some more information

Bareword "exp_continue" not allowed while "strict subs" in use at perlscript.pl line 421.
perlscript.pl had compilation errors (#1)
(F) With "strict subs" in use,
a bareword is only allowed as a subroutine identifier, in curly brackets or to the left of the "=>"symbol.
Perhaps you need to predeclare a subroutine?

Uncaught exception from user code:
Bareword "exp_continue" not allowed while "strict subs" in use at perlscript.pl line 421.
perlscript.pl had compilation errors.

Replies are listed 'Best First'.
Re: expect module: exp_continue error
by Happy-the-monk (Canon) on Jul 13, 2004 at 11:18 UTC

    To solve the problem, make the following capitalisation change in line 1:

    -    use expect;
    +    use Expect;

    Perl is case sensitive and cannot find the symbol   exp_continue   in the   expect   namespace
    because it lives in the   Expect   namespace only.

    Cheers, Sören

Re: expect module: exp_continue error
by Paulster2 (Priest) on Jul 13, 2004 at 11:11 UTC

    While not an expert in this area (I'm not an expert anywhere!) it appears that you are calling a sub that doesn't exist, at least in any part of the code that you have shown us. What is the sub suppose to be doing? I don't see it. Maybe another monk can see it where I can't.

    Paulster2


    You're so sly, but so am I. - Quote from the movie Manhunter.
Re: expect module: exp_continue error
by chime (Friar) on Jul 13, 2004 at 11:23 UTC

    http://perlmonks.thepen.com/220132.html
    Is an example of using the expect module

    I have edited the node
    I was using Expect in the actual program
    Thanks

      Have you found the issue to theis exp_continue? I came acrossing the same issue.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-20 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found