Solved

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

Posted on 2011-03-21
3
271 Views
Last Modified: 2012-06-27
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,



0
Comment
Question by:Tolgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
wilcoxon earned 250 total points
ID: 35182857
my @lines = $job->body;
my @matched = grep /gMyFile/, @lines;
print "these lines matched:\n", join("\n", @matched), "\n";
0
 

Author Comment

by:Tolgar
ID: 35183018
So how can say if matched then do something?

Thanks,
0
 
LVL 26

Assisted Solution

by:wilcoxon
wilcoxon earned 250 total points
ID: 35183051
if (@matched) {
    # something
}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question