This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# You can also do this (but you don't get the versions): | |
# | |
# perl -MExtUtils::Installed -e '$e = ExtUtils::Installed->new(); print join("\n", $e->modules())' | |
# | |
use strict; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Getting the base from an ActiveDirectory connection | |
use Net::LDAP; | |
my $ldap = ...; # connect to ldap | |
my $dse = $ldap->root_dse(); | |
my @contexts = $dse->get_value('namingContexts'); | |
my $base; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use CPAN; | |
my $file = shift @ARGV; | |
open my $fh, $file or die "Can't open $file: $!\n"; | |
my @modules = <$fh>; | |
chomp @modules; | |
close $fh; | |
my $n = scalar @modules; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use Data::Dumper; | |
use Test::More; | |
diag "\n>>> Run as 'prove -v $0'<<<\n"; | |
my $doc =<<EOF; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use Test::More; | |
use Storable qw(dclone); | |
use Data::Dumper; | |
$Data::Dumper::Indent = 1; | |
$Data::Dumper::Sortkeys = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use Capture::Tiny qw(capture); | |
my ($stdout, $stderr, $exitcode) = capture { | |
system("ls", "/", "/nosuchdir"); | |
}; | |
print "STDOUT: $stdout\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Checking for STDIN in Perl | |
# Use -t to test STDIN and STDOUT: | |
sub i_am_interactive { return -t STDIN && -t STDOUT;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Net::LDAP; | |
my $user = $ENV{LDAP_USER}; | |
my $pass = $ENV{LDAP_PASS}; | |
my $host = $ENV{LDAP_HOST}; | |
my $ldap = Net::LDAP->new($host); | |
die "can't connect to $host $!" unless $ldap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select TIME_FORMAT(SEC_TO_TIME(endtime - runtime),'%Hh %im'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# default root directory for goplay | |
GOPLAY_ROOT=""$HOME/goplay"" | |
# fn:goplay:create a go playground | |
function goplay() { | |
local module_name="${1:-anon}" | |
local ts="$(date +%Y-%m-%d_%H%M%S)" | |
local dirname="$GOPLAY_ROOT/$module_name-$ts" | |
local go_version=$(go version | awk '{print $3}' | sed -e 's/go//' | awk -F. '{print $1"."$2}') |
OlderNewer