#!/usr/bin/env perl # # what - extract SCCS/RCS version information from a file # # Usage: # what [ -s ] [-p pattern ] filename ... # # Searches each file listed for '@(#)' and prints all text following, # up to a newline, double-quote, >, or null. # # With -s flag only the first occurance is printed, otherwise # all occurances in the file are printed. # # With -p the pattern is searched for instead of '@(#)'. # This should be a regular expression # # The 'what' command was originally a part of SCCS, but I find it # also useful with RCS, as demonstrated here. If it's not available # already, this perl script is a working substitute. # # Eric Myers - 24 July 1998 # Department of Physics, University of Michigan, Ann Arbor # @(#) $Id: what,v 3.4 2002/03/15 23:39:11 myers Exp $ ###################################################################### require "getopts.pl"; &Getopts('sp:'); $Pattern="@\\\(#\\\)"; # default search pattern if ( $opt_p ) { $Pattern=$opt_p; } foreach $file ( @ARGV ){ open(IN, $file) || ( print("what: $file not found.\n") && next ); print "$file:\n"; while () { while ( /$Pattern/ ){ s/$Pattern([^"\\>\000\n]*)//; print "\t$1\n"; if ( $opt_s ) { close IN; last ; } } } close IN; } exit;