1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 10:55:40 -04:00

Add $^W support for warnings in perl 5.0-5.5

This commit is contained in:
Ryan Voots 2017-12-09 11:34:49 -05:00
parent 5aefaaef27
commit 253ebf9d94
2 changed files with 8 additions and 4 deletions

View file

@ -96,7 +96,7 @@ sub get_namespaced_factoid {
$channel = $forcechan // $channel;
$server = $forceserver // $server;
return $body if $channel eq '*irc_msg' or $channel eq '##NULL';
return $body if $channel eq '*irc_msg' or $channel eq '##NULL';
if ($body =~ /^(?:\s*(?<command>$commands_re|macro)\s+)?(?<body>.*)$/) {
#my ($command, $body);
@ -631,6 +631,8 @@ sub get_fact_learn {
sub get_fact_search {
my( $self, $body, $name ) = @_;
my $namespace = $self
$body =~ s/^\s*for\s*//; #remove the for from searches
my $results;
@ -665,7 +667,7 @@ sub get_fact_search {
my $ret_string;
for( @$results ) {
#i want a better string here, i'll probably go with just the subject, XXX TODO
$ret_string .= "[" . _fact_literal_format($_) . "] " if ($_->{predicate} !~ /^\s*$/);
$ret_string .= "[" . _fact_literal_format($_) . "]\n" if ($_->{predicate} !~ /^\s*$/);
}
return $ret_string;

View file

@ -92,9 +92,11 @@ sub command {
$code = eval {Encode::decode("utf8", $code)} // $code;
if ($command =~ /^([ws]+)?(?:eval|deparse)/i) {
if ($command =~ /^([ws]+)?(?:eval|deparse)(?:5\.(\d+))?/i) {
my $c=$1;
$code = "use warnings; ".$code if ($c =~ /w/);
my $v=$2;
$code = "use warnings; ".$code if ($c =~ /w/ && $v>=6);
$code = '$^W=1;'.$code if ($c =~ /w/ && $v < 6);
$code = "use strict; ".$code if ($c =~ /s/);
}