- Timestamp:
- 07/31/09 09:37:29 (4 years ago)
- Location:
- lang/perl/Script-Carp/trunk
- Files:
-
- 2 modified
-
Changes (modified) (1 diff)
-
lib/Script/Carp.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Script-Carp/trunk/Changes
r33935 r34681 1 1 Revision history for Script-Carp 2 3 0.04 2009-07-31 09:35:00 4 add beep. 2 5 3 6 0.03 2009-06-13 15:12:00 4 7 fix test script. 8 add log. 5 9 6 10 0.02 2009-06-08 14:37:59 -
lang/perl/Script-Carp/trunk/lib/Script/Carp.pm
r33935 r34681 13 13 if (defined $_[0] and $_[0] =~/^Died /) { 14 14 $_die->(@_) 15 } elsif (defined $_[0] and $_[0] =~/ at $filename line $line\./) { 16 $_die->('Died ', @_); 15 17 } else { 16 18 $_die->('Died ', @_, " at $filename line $line.\n") … … 47 49 close $out; 48 50 }; 51 }, 52 -beep => sub { 53 local $@; 54 eval "require Audio::Beep"; 55 unless ($@) { 56 my ($args) = @_; 57 $args->[0] ||= "g'"; 58 my $beep = $args->[0] =~/^-/ ? "c' d' e'" : shift @$args; 59 return sub { 60 Audio::Beep->new->play($beep); 61 } 62 } else { 63 my $msg = "You need Audio::Beep module."; 64 $msg .= ' you may need "modprobe pcspkr" and/or "xset b on"' if $^O =~/linux/i; 65 warn $msg; 66 return sub {}; 67 } 49 68 }, 50 69 -ignore_eval => sub { … … 99 118 =cut 100 119 101 our $VERSION = '0.0 3';120 our $VERSION = '0.04'; 102 121 103 122 … … 108 127 use Script::Carp -stop; # display error and wait STDIN 109 128 use Script::Carp -file => "error.txt"; # write message to error.txt 129 use Script::Carp -stop, -file => "error.txt"; # mixed the above 110 130 use Script::Carp -log => "error_log.txt"; # append message to error_log.txt 111 use Script::Carp -stop, -file => "error.txt"; # mixed the above 131 use Script::Carp -beep => "c d e f g"; # beep 132 112 133 113 134 use class method with options … … 117 138 Script::Carp->setup(-log => "error_log.txt"); 118 139 Script::Carp->setup(-stop, -file => "error.txt"); 140 Script::Carp->setup(-beep => "c d e f g"); 119 141 120 142 =head1 DESCRIPTION … … 163 185 It is like file, but it will not clear file content. 164 186 When script died, messages are appended to "log_file_name". 187 188 =head2 -beep 189 190 use Script::Carp -beep; 191 use Script::Carp -beep => "c d e f g"; 192 193 or 194 195 Script::Carp->setup(-beep); 196 Script::Carp->setup(-beep => "c d e f g"); 197 198 beep when died. It requires Audio::Beep module. 199 If you use Linux, you may need to 'modprobe pcspkr", 'xset -b on' 165 200 166 201 =head1 METHOD
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)