How to assign to an array or variable and check the existance of a string in it?


#returns an array of lines

Open in new window

I want to assign the output of the previous line to a variable or array and then check if there is any line in the job body that has 'gMyFile' string in it.

How can I make it in Perl?


Who is Participating?
wilcoxonConnect With a Mentor Commented:
my @lines = $job->body;
my @matched = grep /gMyFile/, @lines;
print "these lines matched:\n", join("\n", @matched), "\n";
TolgarAuthor Commented:
So how can say if matched then do something?

wilcoxonConnect With a Mentor Commented:
if (@matched) {
    # something
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.