in reply to Perl Expect : Get the complete matched string
#!/usr/bin/perl # http://perlmonks.org/?node_id=1168984 use strict; use warnings; use Expect; my $exp = Expect->spawn('echo -e "local backup succeeded.\n\nBackup +file location: /var/log/CPbackup/backups/x.x/x.x.x.x_01_1_Aug_2016_11 +_05.tgz\n\nBackup process finished in 00:48 seconds"') or die; my ($pos, $error, $matched, $before, $after) =$exp->expect( 10, ['-re',qr/Backup file location:[^\r\n]*/,sub {my $exp = shift; + } ], ['-re',qr'>'] ); print "\n\n\nfound: <<<$matched>>>\n";;
|
|---|