#!/usr/bin/perl

$file=undef;

@args=();

foreach $arg (@ARGV) {
	if ($arg =~ /^-/) {
		# it's a command-line argument, put it on the stack
		push(@args, $arg);
	} else {
		# it's a filename, it's the file to print
		$file=$arg;
	}
}

# build command string and pass eventual options (stacked
# in @args) to lpr:
if ($file) {
	$cmd="psset -q --duplex < $file | lpr ".join(" ", @args);
} else {
	$cmd="psset -q --duplex | lpr ".join(" ", @args);
}

# execute the command
qx[$cmd];

