All this scratching is making me itch.
For scratch. Print serial numbers from a file that are not included in another "subset" file. Both files must be sorted:
#!/usr/bin/perl -w
use strict;
die "Usage: $0 subset serial\n" unless @ARGV == 2;
my $subset = shift;
my $serial = shift;
open SUBSET, $subset or die "Couldn't open $subset: $!\n";
open SERIAL, $serial or die "Couldn't open $serial: $!\n";
while (<SUBSET>) {
my $subset_num = $_;
my $serial_num;
print $serial_num while ($serial_num = <SERIAL>) < $subset_num
+;
}
print while <SERIAL>;
__END__
The following works for unsorted files but is less efficient than the above example:
#!/usr/bin/perl -w
use strict;
die "Usage: $0 subset serial\n" unless @ARGV == 2;
my $subset = shift;
my $serial = shift;
open SUBSET, $subset or die "Couldn't open $subset: $!\n";
open SERIAL, $serial or die "Couldn't open $serial: $!\n";
my %used;
$used{$_}++ while <SUBSET>;
while (<SERIAL>) {print unless $used{$_}}
__END__
# Find the version number of a module
perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Some::M
+odule
# Check if a module is installed
perl -le 'print 0 + eval "require $ARGV[0]" ' Some::Module
# Or this mnemonic cheat
perl -exists -MSome::Module
# Plain silly
$ perl -wevest
String vest may clash with future fashion at -e line 1.
|