From: Roland G. <RGi...@cp...> - 2003-08-22 08:37:18
|
From the Expect docs: Furthermore, patterns can now be specified as array refs containing [$regexp, sub { ...}, @optional_subparms] . When the pattern matches, the subroutine is called with parameters ($matched_expect_obj, @optional_subparms). Wu, LT (=A7d=CD=DD=BCw IEC1) wrote: > Hi, > =20 > I'm having this problem. > I know we can use subroutine in this way, > =20 > [ timeout =3D> sub{$exp->send("quit\n");}], > =20 > or call a subroutine in this way, > =20 > [ qr/SQL>/i =3D> \&dothis ], > =20 > but I want to pass parameters along with the subroutine call, > so I write in this way, > =20 > [ timeout =3D> sub{$exp->send("quit\n");}], > [ qr/SQL>/i =3D> \&dothis(param) ], this would be [ qr/SQL>/i =3D> \&dothis, param ], > but it generated such error message: > =20 > "Pattern #2 doesn't have a CODE referenceafter the pattern" > =20 > Then the timeout in 1st line cannot work, > although the subroutine did receive the parameter. > =20 > So that means I cannot pass any parameters within Expect statement. > How can I solve this problem? > Thanks. > =20 > =20 > Liang > =20 Hope this helps, Roland |