in reply to if condition within module
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
|
---|