Using expect in Perl, how to add options of ignoring case with method $object->expect()?

186 Views Asked by At

This is example found in perldoc:

  $object->expect(15, '-re', "$str");

I want to add option 'i' to the match. This won't work:

$object->expect(15, '-re', qr/$str/i);

Do I have to use this format:

 $exp->expect($timeout, [ qr/$str/i, sub {}], $shell_prompt);
1

There are 1 best solutions below

2
On

You can embed directives into the regex itself:

$object->expect(15, '-re', "(?i)$str");

ref: http://perldoc.perl.org/perlre.html#Extended-Patterns