in reply to Perl Expect : Get the complete matched string
Hi cryptonite1,
I haven't used Expect much, but the documentation says
If called in an array context expect() will return ($matched_pattern_position, $error, $successfully_matching_string, $before_match, and $after_match).
So that would mean something like
my ($match_pos, $error, $match_string, $before_match, $after_match) = +$exp->expect( $timeout, ... );
(Untested) Update: Fixed a copy/paste mistake, and I tried it out and in your case you'll probably be interested in the string $after_match, since that will contain the rest of the line after the regex "Backup file location:". It'll still have whitespace and newlines on the ends of the string, so you'll have to do something like $after_match =~ s/^\s+|\s+$//g; to get rid of it.
Hope this helps,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Expect : Get the complete matched string (updated)
by cryptonite1 (Initiate) on Aug 02, 2016 at 10:42 UTC | |
by haukex (Archbishop) on Aug 02, 2016 at 18:45 UTC |