Skip to content

Instantly share code, notes, and snippets.

View exodist's full-sized avatar

Chad Granum exodist

View GitHub Profile
@exodist
exodist / temp.pl
Created November 1, 2023 23:05
Use of uninitialized value $exit in exit at (file) line (20)
sub process_and_exit {
my $self = shift;
my ($child_pid) = @_;
my $guard = Scope::Guard->new(sub {
eval { $self->_die("Scope Leak inside collector") };
exit(255);
});
my $exit = 0;
sub cli_docs {
my $self = shift;
my @forms = $self->doc_forms;
require App::Yath::Util;
require Test2::Util::Term;
my $width = Test2::Util::Term::term_size() - 20;
$width = 80 unless $width && $width >= 80;
106 my $last_write = time;
107 $self->{stream} = sub {
108 my $responder = shift;
109 my $writer = $responder->([200, \@headers]);
110
111 my $end = 0;
112 while (!$end) {
113 $end = $done->();
114
115 my $seen = 0;
@exodist
exodist / wtf
Last active December 8, 2020 19:26
wtf?
exodist@abydos main $ perl -e 'BEGIN { *foo = sub { 512 } }; my $xxx = 16; my $yyy = foo - $xxx; print "$yyy\n";'
512
foo() instead of foo fixes it
exodist@abydos main $ perl -e 'BEGIN { *foo = sub { 512 } }; my $xxx = 16; my $yyy = foo() - $xxx; print "$yyy\n";'
496
using sub() to define foo also fixes it.
exodist@abydos main $ perl -e 'BEGIN { *foo = sub() { 512 } }; my $xxx = 16; my $yyy = foo - $xxx; print "$yyy\n";'
496
@exodist
exodist / test.pl
Created November 23, 2020 20:52
example
my $ctx = Test2::API::context();
$ctx->fail("oops");
$ctx->release
@exodist
exodist / output
Created November 23, 2020 20:38
test
perl test.pl
# Seeded srand with seed '20201123' from local date.
ok 1 - hi
# foo
ok 2 - thesubtest {
ok 1 - hi
# foo
1..1
}
1..2
@exodist
exodist / output
Created August 9, 2020 01:39
why?
!perl xxx.pl
Can xxx()
Undefined subroutine &main::xxx called at xxx.pl line 10.
Undefined subroutine &main::xxx called at xxx.pl line 11.
keyword BAREWORD_NAME(PARAMS) {BLOCK}
keyword "QUOTED_NAME"(PARAMS) {BLOCK}
Where (PARAMS) are optional.
For params I honestly want to just turn it into {PARAMS} treat it like a hashref definition cause it will always have key/value pairs.
package Test2::Plugin::Cover;
use strict;
use warnings;
our $VERSION = '0.000001';
use XSLoader;
XSLoader::load(__PACKAGE__, $VERSION);
1;
Perl_ppaddr_t orig_subhandler;
static OP* my_subhandler(pTHX) {
OP* out = orig_subhandler(aTHX);
char *file = CopFILE(cCOPx(out));
printf("xxx %s\n", file);
return out;
}