sub BuildMMList { ## enforce strict programming methods (see strict) ## if you can't do this for the whole script, do it in each ## subroutine until the whole script has been refactored ## while you're at it, use warnings, too (see warnings) use strict; use warnings; ## pass parameters to the subroutine -- global variables are trouble ## assign the passed parameters to variables local to the scope of the sub my( $list, $mm_file ) = @_; ## use the three parameter form of open (see perlfunc) ## localize your filehandles to avoid namespace pollution ## don't quote variables unneccessarially (see perlvar) ## don't use the '&' sigil when calling subs (see perlsub) ## make your error messages verbose open( local *FILE, '<', $mm_file ) or error_message( "$0: Can't open data file: $mm_file: $!"); ## use a while loop to process the file in memory ## this avoids temp variables, and avoids c-like for loops while( <*FILE> ) { ## use the 3-arg form of split to limit fields ## throw away other fields by assigning to 'undef' my( $opt, undef ) = split /``/, $_, 2; ## use quote operators, so quote characters don't need to be escaped print qq{\n}; } } #### .