Skip to content

Instantly share code, notes, and snippets.

@RubeRad
RubeRad / diffnum.pl
Created February 25, 2011 18:27
Compare numbers in two line-for-line corresponding files
#! /bin/perl
# diffnum.pl
use Getopt::Std;
$opt{t} = 0.0;
getopts('t:', \%opt);
$f1 = shift @ARGV;
$f2 = shift @ARGV;
@RubeRad
RubeRad / multi.pl
Created February 25, 2011 17:50
Construct and execute multiple 2-argument commands using patterns to specify input/output pairs
#! /bin/perl
# multi.pl
# Parse command-line switches
use Getopt::Std;
%opt = ();
getopts('htqorlgO:', \%opt);
$usage = "Usage: multi.pl [-hqorlt] cmd before_pat after_pat [files]\n";
@RubeRad
RubeRad / subinplace.pl
Created February 25, 2011 17:48
Open ascii files, make substitutions, and write them back out
#! /bin/perl
# subinplace.pl
use Getopt::Std;
%opt = ();
getopts('tvsSh', \%opt);
$usage = "Usage:\n";
$usage .= "subinplace.pl [-htv] 'before_pat' 'after_pat' files...\n";
$usage .= " -h _h_elp\n";
@RubeRad
RubeRad / txt2tff.pl
Created February 25, 2011 17:45
Read in nrows,ncols, followed by nrows lines of ncols whitespace-separated pixel intensities. Output .tff
#! /bin/perl
# txt2tff.pl
use Getopt::Std;
$opt{x} = 1;
getopts('x:o:', \%opt);
# determine the dimensions, create an empty 2D matrix
$_ = <>;