0

I am new to Perl and am trying to write a script to do the following.

I have an array, basically its an output of a command.

BIP: Message flow 'Message Flow name' on execution group 'EG' is running.(There are bunch of similar lines)

So I am using foreach $_(@array name) to read each line.

Now I just want the Message Flow name from the array and want to change running to started. and get that in the OP too. So, I want to get:

Message Flow Name,started as my OP.

Can you please help? I tried splice, split but no use.

Thanks in advance.

2
  • How about some of your code that has failed, some sample input and sample desired output? Commented Nov 6, 2013 at 13:23
  • try regex instead of splice and split Commented Nov 6, 2013 at 13:30

1 Answer 1

1

Try this

#!/usr/bin/perl

use strict;
use warnings;

my @messages = ("BIP: Message flow 'Name1' on execution group 'EG' is running", "BIP: Message flow 'Name2' on execution group 'EG' is running");
for (@messages) {
    if (/BIP: Message flow '(.*?)' .* running/) {
        print("$1 started as my OP\n");
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

This worked like a charm. Thanks a ton for the immediate help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.