On Feb 5, 2013, at 2:39 PM, Rajeev Prasad wrote: > Hello, > > I have a working sub like this: > > sub captureexpectout { > my $data_coming_in_from_expect_call = shift; > ...do something with data.. > ... > ... > } > > which i am calling like this: > > $expect->log_file(\&captureexpectout); > > > Now I want to call this subroutine with arguments. I tried below but I got > error... > > $expect->log_file(\&captureexpectout($_,$myarg));
You are passing a code reference to the $expect->log_file() subroutine. You cannot include arguments with that code reference, as it is just a scalar value that will be saved by the Expect object and used later, Like this: sub log_file { ... $code_ref = shift; and then later used like this: $code_ref->(@args); > I was assuming that the data from expect call is contained in $_ > > but i get nothing. (seems like it passes blank to subroutine...) > Normal data passed to subroutines is contained in @_ (not $_). Your shift command will pop off the first element of @_, however, so you should see something if it is being passed. Unfortunately, the documentation does not specify what, if anything, is passed to your subroutine. Make sure you are calling $expect->log_file() early in your program. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/