From: Robin Edwards <robin.ge@gmail.com>
Date: Mon, 14 Dec 2009 14:48:54 +0000 (+0000)
Subject: added debug mode
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f584ca09e1e7fb1b6487f488a9840c5f9786999f;p=p5sagit%2FDevel-Declare-Keyword.git

added debug mode
---

diff --git a/lib/Keyword.pm b/lib/Keyword.pm
index d831fbd..9e3360e 100644
--- a/lib/Keyword.pm
+++ b/lib/Keyword.pm
@@ -15,7 +15,7 @@ our $DEBUG = 0;
 
 #setup parser for keyword syntax
 sub import {
-	$DEBUG = 1 if $_[1] =~ /debug/i;
+	$DEBUG = 1 if $_[1] and $_[1] =~ /debug/i;
 
 	Devel::Declare->setup_for(
 		$KW_MODULE,
@@ -148,7 +148,7 @@ sub kw_proto_to_code {
 	return $inject;
 }
 
-sub debug { warn @_ if $DEBUG; }
+sub debug { warn "DEBUG: @_\n" if $DEBUG; }
 
 #converts prototype to a list of parse and action subs
 sub proto_to_parselist {
@@ -252,7 +252,7 @@ Keyword - an easy way to declare keyword with custom parsers
 =head1 SYNOPSIS
 
  package Method;
- use Keyword;
+ use Keyword 'debug';
 
  keyword method (ident?, proto?, block) {
    	 $block->name($ident); # assign the block to subroutine