-1

I have a variable $data which contain a bunch of data; I want to mach if either of two pattern present in the variable the condition is true so i write the code like

if ( $data =~ m/"Restore actions:"|"Setting Changes:"/)

and I put a print statement in the else condition

unfortunately its always going to the else even though these two patterns are present in the variable.

below is the data contain by the $data variable

sd: Save time:   Thu ...
sd: ...
sd: Restore actions:
sd: ...
sd: Setting Changes:
sd: ...
ikegami
  • 367,544
  • 15
  • 269
  • 518
user1068861
  • 111
  • 1
  • 8
  • Trying to erase history is moot. It's still all in [here](http://stackoverflow.com/posts/8292585/revisions). Worse, changing it so the question and the answers make no sense. – ikegami Jul 25 '12 at 05:26
  • Furthermore, claiming you own the word "yinst" is just plain stupid. If you don't want people to know you use `yinst`, don't tell them. – ikegami Jul 25 '12 at 05:27
  • If I use my own word or change the question or if it's plain stupid; it's mine don't be part of the stupid like an extraordinary stupid gentleman .... I must say you got my message – user1068861 Jul 26 '12 at 05:27
  • You are mistaken. This is a collaborative site. It's not *your* question after you post it. Refer to the FAQ. – ikegami Jul 26 '12 at 15:06

2 Answers2

3

Try it like this:

if ( $data =~ m/(Restore actions:|Setting Changes:)/)
pointer
  • 579
  • 3
  • 5
3

You included quotes that don't appear in the text you are trying to match.

if ( $data =~ /Restore actions:|Setting Changes:/ )

and the more precise

if ( $data =~ /^sd: (?:Restore actions|Setting Changes):/m )

will do.

ikegami
  • 367,544
  • 15
  • 269
  • 518