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

Hi,

#returns an array of lines
$job->body; 

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?

Thanks,



TolgarAsked:
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";
0
 
TolgarAuthor Commented:
So how can say if matched then do something?

Thanks,
0
 
wilcoxonConnect With a Mentor Commented:
if (@matched) {
    # something
}
0
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.