#!/usr/bin/perl -w # +++ consider -T for taint-checks # +++ consider Perl::Critic ###################################################################### # qso.pl by "Nosey" Nick Waterman of Nilex # http://noseynick.org/ # (C) Copyright 2010 Nilex - All wrongs righted, all rights reserved. ###################################################################### # Requirements: use 5.008; use strict; use warnings; # use diagnostics; use Getopt::Long qw(:config gnu_getopt); # command-line option handlers and defaults my %opt = ( 'help' => sub { die "help:\n" }, 'start' => 0, 'end' => 100, 'y' => 0, 'w' => 1, 'n' => 1, 'm' => 2, ); my $usage = "USAGE: $0 [options] This will make a list of 'gnuplot' commands to draw rectangles that look a bit like a QSO. Used to create ftdma2.gnuplot, for example. options include: --start [$opt{start}]\tinitial x coord --end [$opt{end}]\tend x coord --y [$opt{y}]\ty coord --w [$opt{w}]\tbandwidth of signal --n [$opt{n}]\tcolour number (linetype) of first participant --m [$opt{m}]\tcolour number (linetype) of last participant "; GetOptions(\%opt, qw(help|? debug|d! start|s=f end|e=f y=f w=f n=i m=i)) or die $usage; die $usage if @ARGV; # Do stuff: my ($x, $t) = @opt{"start", "n"}; while ($x<100) { print "set object rectangle from ", int($x), ",$opt{y} to "; $x += 1+rand(15); print int($x), ",", $opt{y}+$opt{w}, " fc lt $t\n"; $x += rand(2); $t++; $t=$opt{n} if $t>$opt{m}; } 1; # as if we're ever going to get called as a module - hah! __END__ (C) Copyright 2010 Nilex - All wrongs righted, all rights reserved.