#!/usr/bin/perl use strict; # Restrict a journal data set by column if( !@ARGV ) { print "Usage: restrictcol \'//\'\n"; exit(0); } # Read in the arguments my %cols; while( $_ = pop(@ARGV) ) { (/(\d)+\/([^\/]+)\// && ($cols{$1} = $2) && print STDERR "Comparing col $1 with $2\n") || print STDERR "Unrecognised argument $_\n"; } # Parse the input while( ) { split; my $pr = 1; my $key; foreach $key (keys %cols) { (@_[$key] =~ /$cols{$key}/) || ($pr = 0 && last); } ($pr && print); }