set_uk has asked for the wisdom of the Perl Monks concerning the following question:
Run Perl::Expect in debug and internal mode - output below. Where it shows what it is trying to match and the regex it is using.
Matches OK when using a script to match the string and the same regex.
I have tried $Expect::Multiline_Matching = 0 and = 1 for the same effect.
This is the code from the Expect.PM re multiline matching.spawn id(4): Does ` #00 LOGGED IN NORTEL1 12:02 3/11/2003 \r\n\r\012 +>logo\r\r\012TTY #00 LOGGED OUT NORTEL1 12:02 3/11/2003 \r\012SESSI +ON DURATION: 00:00 \r\012\r\012>' match: pattern #1: -re `LOGGED OUT.*TTY'? No. pattern #2: -re `LOGGED OUT.*>'? No.
Any pointers as to why this isn't working? Update:- Simplifying this problem out of Expect:- Why does the following not match:-} elsif ($pattern->[1] eq '-re') { # m// in array context promises to return an empty list # but doesn't if the pattern doesn't contain brackets (), # so we kludge around by adding an empty bracket # at the end. if ($Expect::Multiline_Matching) { @matchlist = (${*$exp}{exp_Accum} =~ m/$pattern->[2]()/m); ($match, $before, $after) = ($&, $`, $'); } else { @matchlist = (${*$exp}{exp_Accum} =~ m/$pattern->[2]()/); ($match, $before, $after) = ($&, $`, $'); }
Nothing returned#!/usr/bin/perl -w use strict; use warnings; use diagnostics; my $String = "` #00 LOGGED IN NORTEL1 12:02 3/11/2003 \r\n\r\012>log +o\r\r\012TTY #00 LOGGED OUT NORTEL1 12:02 3/11/2003 \r\012SESSION D +URATION: 00:00 \r\012\r\012>"; my @matchlist = ($String =~ m/(.*LOGGED OUT.*>)/m); print @matchlist;
20031103 Edit by jeffa: Changed title from 'Perl::Expect - Regular Expression not matching ', added strikes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect.pm - Regular Expression not matching
by Abigail-II (Bishop) on Nov 03, 2003 at 12:11 UTC | |
by set_uk (Pilgrim) on Nov 03, 2003 at 12:47 UTC | |
|
Re: Expect.pm - Regular Expression not matching
by Anonymous Monk on Nov 03, 2003 at 12:31 UTC | |
by set_uk (Pilgrim) on Nov 03, 2003 at 12:44 UTC |