Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: if condition within module

by wjw (Priest)
on Aug 15, 2017 at 15:11 UTC ( [id://1197437]=note: print w/replies, xml ) Need Help??


in reply to if condition within module

Perhaps your question is a bit unclear because of the terminology you are using. I am assuming that you are pretty new to Perl(and perhaps programming in general?).

I am not familiar with Data::Table, so will offer my suggestion outside the scope of what it might be capable of. You can use an if statement pretty much anywhere in your code that you wish: In a sub, in a module, it does not matter. Based on what you state that you want, a code snippet that would work might look like the following:

if ($col6 =~ /^\Q97517\E/ ) { --do somethng -- } elsif ($col6 =~ /^\Q97516\E/) { --do something else -- }

The --do something(s) -- can be what whatever you want them to be.

If you are up against a time constraint, such as an assignment due, it will be much faster to look in the documentation for Data::Table. There is an example about half way down that shows the use of an if() conditional.

There is no better way to learn Perl and programming in general than to take a problem one wants to solve and figure out how to solve that problem using the language. But you have to take the time to learn the terminology so that you can ask questions which are clear when seeking help. Learning takes time, and time constraints are not conducive to learning programming in my experience....

...the majority is always wrong, and always the last to know about it...

A solution is nothing more than a clearly stated problem...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2024-04-24 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found