Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Chat Script - Logging PMs

by AllenMichael (Initiate)
on Jan 18, 2013 at 16:59 UTC ( [id://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;

So...in 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found