Expect.pm passing $exp to subroutine ** line number correction

[email protected] (Noah)
Newsgroups perl.beginners
Message-ID <[email protected]>
Hi,

thank you again list members for the quick response to my last question.

I am using the I am trying to figure out to pass my $exp to the
subroutine "grabConfig".  $exp is the variable of my expect object.
line 167 is "$patidx = $exp->expect($timeout, [$prompt]); "


here is the error message:

"                   Please Enter Selection: > Can't call method "expect"
on an undefined value at ./get.config.pl line 167."

here are snippets from my code:

---- snip ---

                     # send element number
                     while ($elementCount < $elementUpperLimit) {

                         $prompt = "$blah";
                         $exp->send("$elementCount");

                         &grabConfig;

                         $elementCount++;
                     }


sub grabConfig {
     $prompt = "^$user\@[a-z\.0-9\-]+>";

     $patidx = $exp->expect($timeout, [$prompt]);  <<<<<< line 169
     $read = $exp->before();

     #get hostname
     $read =~ /^@([^>]+)>\s/;
     $hostname = $1;
     $hostname = tr/[a-z]/[A-Z]/;
     $outputFilename = "$hostname.config.txt";

     #delete saved configuraiton file
     unlink ($outputFilename);

     # open new configuration file
     open (OUTPUT, ">$outputFilename");



---- snip ----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.