#! perl -slw use strict; use G; ## Expands wildcards arguments as would be done by most *nix shells. our $INDEX ||= 'words.index'; my %index; if( -e $INDEX ) { open INDEX, '<', $INDEX or die "$INDEX: $!"; m[^([^:]+):(\d+)$] and $index{ $1 } = $2 while ; close INDEX; } while( my $file = @ARGV ) { open FILE, '<', $file or warn "$file:$!" and next; while( ) { $index{ $_ }++ for split ' '; } close $file; } my( $key, $val ); open INDEX, '>', $INDEX or die "$INDEX : $!"; print INDEX "$key:$val" while ( $key, $val ) = each %index; close INDEX;