Search
Results
Perl LWP Discord Webhook
sub discord { use LWP; use HTTP::Request; use JSON; my ($_a) = @_; my ($_r); my $_msg = { 'username' => 'chsm-ext', 'content' => $_a, }; my $_json = JSON->new->allow_nonref; my $_ua = LWP::UserAgent->new; my $_req = HTTP::Request->new(POST => 'https://discord.com/api/webhooks/'.$app->{'discord'}); $_req->content_type('application/json'); $_req->header("User-Agent" => "Perl Discord HookBot"); $_req->content($_json->encode($_msg)); $_r = $_ua->request($_req); return $_r; }
Perl Time Snippet
my @now = localtime; $now[5] += 1900; $now[4] += 1; for my $l (0 .. (scalar(@now) - 1)) { $now[$l] = sprintf("%02d",$now[$l]); }
Perl Key Sort w/Map
my @sorted = map substr($_, 4) => sort map pack('C4' => /(\d+)\.(\d+)\.(\d+)\.(\d+)/) . $_ => keys $output;
Perl Date Array
my @d = localtime; $d[5] += 1900; $d[4] += 1; for my $l (0 .. (scalar(@d) - 1)) { $d[$l] = sprintf("%02d",$d[$l]); }
Loading data from file
for my $s (0 .. (scalar(@source_list) - 1)) { print " - Loading: $source_list[$s]\n"; push(@sources,do "$srpz_home/sources/$source_list[$s]\.pl"); }