Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

G'day gowthamvels,

I want to use a if conndtion like below ...

if ($col6 =~ /^\Q97517\E/ } elsif $col6 =~ /^\Q97516\E/))

The very first thing you should do is read "Perl introduction for beginners" because, from what you've demonstrated, you do not, at present, have a basic understanding of Perl code syntax.

if can be used in a compound statement. The construct looks like this:

if (CONDITION) { ACTION_WHEN_CONDITION_IS_TRUE }

That may be followed by zero or more alternative conditions and actions:

elsif (ALTERNATIVE_CONDITION) { ACTION_WHEN_ALTERNATIVE_CONDITION_IS_TRUE }

Finally, all of that may be optionally terminated with:

else { ACTION_WHEN_CONDITION_IS_FALSE }

This is documented in "perlsyn: Compound Statements".

if may also be used as a statement modifier:

ACTION_WHEN_CONDITION_IS_TRUE if CONDITION;

This is documented in "perlsyn: Statement Modifiers".

There is also an "if pragma". This does not appear to have anything to do with what you're currently attempting; however, be aware of it to avoid confusion in other (unrelated) code, discussions or documentation.

Perl has no builtin if() function. I mention this because "if()" has been used in a number posts in this thread (including by yourself: "I am asking for how to use the if() in this code") and that usage could be confusing to a Perl novice.

— Ken


In reply to Re: if condition within module by kcott
in thread if condition within module by gowthamvels

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 09:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found