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

Chat Script - Logging PMs

by AllenMichael (Initiate)
on Jan 18, 2013 at 16:59 UTC ( #1014090=perlquestion: print w/replies, xml ) Need Help??
AllenMichael has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am still learning Perl but I'm working on my first project which is a Perl chat script. All has been going well but I'm stuck on how to make one of my features work. This chat script logs public messages by default but I have given the admin the option to choose if they want private messages to be logged or not. Ok so I'm stuck on how to write this out and make it work. The chat has a config file where this option can be enabled by setting the variable to 1. The variable for turning this on is:

 $pm_log = 1; my script, so far I've gotten

if($pm_log) { &logfile("(PRIVATE-MSG)") } elsif ($pm_type eq "private") { &logfile("(PRIVATE) [$pm_from -to- $pm_to] $pm_message +", 3);

for IF $pm_log is on, then do this..... and that is where I'm stuck. What code should be run for this if conditional? Can someone please help...I'm having a moment and I'm just stuck here. If I'm not mistaken...doesn't this mean IF pm_log is true, log private messages elsif still log private messages? I want this to be an optional feature that the admin of the chat can choose. Thanks!

Replies are listed 'Best First'.
Re: Chat Script - Logging PMs
by Anonymous Monk on Jan 18, 2013 at 20:42 UTC

    The elsif and its condition will only be checked when the main if's condition is false.

    This is an exercise in boolean logic I think... if (P) then log(). if (!P and Q) then log().

    Which can simplify to: if (Q or P) then log()

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1014090]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-06-23 10:56 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.