Solved

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

Posted on 2011-03-21
3
266 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now