Using Perl::Expect to match a regex. But it isn't when it should!.

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.

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.
This is the code from the Expect.PM re multiline matching.
} 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) = ($&, $`, $'); }
Any pointers as to why this isn't working? Update:- Simplifying this problem out of Expect:- Why does the following not match:-
#!/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;
Nothing returned

20031103 Edit by jeffa: Changed title from 'Perl::Expect - Regular Expression not matching ', added strikes


In reply to Expect.pm - Regular Expression not matching by set_uk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.