Skip to content

Instantly share code, notes, and snippets.

View rwstauner's full-sized avatar
💤
I may be slow to respond.

Randy Stauner rwstauner

💤
I may be slow to respond.
View GitHub Profile
@rwstauner
rwstauner / main.pl
Created April 30, 2012 16:18
trying to figure out win32 STDIN hang with IPC::Open2
$arg = ' ' . shift @ARGV;
$script = qq[perl pipe1.pl $arg];
system(q{perl -e "print qq[hi$/there$/]" | } . $script);
use IPC::Open2 "open2";
$pid = open2($out, $in, $script);
$|=1;
print $in qq[hi$/there$/];
@rwstauner
rwstauner / accessor_maker.pm
Created November 29, 2011 17:52
Devel::Cover 0% branch coverage for externally defined methods
package accessor_maker;
sub import {
no strict 'refs';
*{ caller() . '::' . 'foo' } = sub { $_[0]->{ 'foo' } };
}
1;
@rwstauner
rwstauner / weirdness.pl
Created June 26, 2011 22:12
Perl bug? Weird combination of do, local, and something else? (http://bit.ly/mhaQ4x)
# original weirdness: same result changing local to my and if(){} to bare {}
sub weird {
my ($c) = @_;
if( ref $c ){
return (ref $c eq 'SCALAR' ? 't' : do { local $/; warn "# doing\n"; 'do'; });
}
return 'r';
}
# fix: no local, no my
@rwstauner
rwstauner / perl-syntax-sql.vim
Created June 22, 2011 15:01
highlight SQL syntax in a Perl heredoc
" ~/.vim/after/syntax/perl.vim
let s:bcs = b:current_syntax
unlet b:current_syntax
syntax include @SQL syntax/sql.vim
let b:current_syntax = s:bcs
" match optional, surrounding single or double quote and any whitespace in the heredoc name
syntax region perlHereDocSQL matchgroup=Statement start=+<<\(['"]\?\)\z(\s*SQL\s*\)\1+ end=+^\z1$+ contains=@SQL
#!/usr/bin/env perl
# This chunk of stuff was generated by App::FatPacker. To find the original
# file's code, look for the end of this BEGIN block or the string 'FATPACK'
BEGIN {
my %fatpacked;
$fatpacked{"Devel/PatchPerl.pm"} = <<'DEVEL_PATCHPERL';
package Devel::PatchPerl;
BEGIN {
$Devel::PatchPerl::VERSION = '0.32';