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
my $opt_parser = OptParser->new(); | |
$opt_parser->add_option( | |
name => "foo" # name used to refer to this option | |
short => "f" # use as -f | |
long => "foo" # use as --foo | |
depends => "bar|baz" # option only valid if bar or baz is specified. using | |
# an array to list depends may be simpler... or not | |
conflicts => "buh" # option conflicts with option buh. |
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
use strict; | |
use warnings; | |
use feature ":5.10"; | |
my @ar = qw( a b c d ); | |
my $ar_ref = \@ar; | |
say @ar; # abcd | |
say @$ar_ref; # abcd - same array, so same contents |
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 warnings; | |
use English qw( -no_match_vars ); | |
use Data::Dumper; | |
use EV; | |
use AnyEvent; | |
use AnyEvent::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
#!/bin/bash | |
set -e | |
tar czf rrds.tar.gz rrds/ | |
find rrds/ -name '*.rrd' \ | |
| xargs -P8 -I{} bash -c ' | |
set -e | |
echo "{}" | |
./rrd-clone.pl "{}" "{}.new" |
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
use feature ':5.10.0'; | |
package Foo; | |
use Text::Template; | |
# needs to be in scope for Text::Template's processing | |
my %data; | |
sub get_metadata { | |
my ($tmpl) = @_; | |
return Bar::get_metadata($tmpl); |
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
#!/bin/bash | |
# relpath -- Compute relative path from a given DIR to given PATHs | |
# Usage: relpath DIR PATH... | |
# | |
# Example: relpath /a/b/c /a/d/e/f | |
# prints: ../../d/e/f | |
# | |
# Example: relpath /a/b/c / | |
# prints: ../../../ | |
# |
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
#!/bin/bash | |
# | |
# Summary: | |
# This script will set up your environment et al so you can run the Hive | |
# Query Tool. This script is intended to be sourced, but can be run without | |
# sourcing. The /path/to/perl argument(s) are optional. | |
# | |
# Usage: | |
# source setup-hqt [/path/to/perl /path/to/other/perl ...] | |
# setup-hqt [/path/to/perl /path/to/other/perl ...] |
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
#!/bin/bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
source /bath/to/bash-getopt | |
foo_dflt="wibble" | |
bash-getopt "$@" <<END_OPTS |
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
#!/bin/bash | |
# | |
# This is a simple script to allow someone on an RPM-based | |
# system to build the custom opt-perl package defined by | |
# the RPM specfile in this same directory. | |
# | |
# @author: Stephen R. Scaffidi <[email protected]> | |
# @date: Oct. 2012 | |
# |
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
#!/bin/bash | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
host="$1" | |
port="$2" | |
starttls_prot="${3:-}" # xmpp, smtp, pop3, imap, or ftp (optional) |
OlderNewer