#!/usr/bin/perl # Routine to add quotes to all FILTER_NAME fields in the PDS labels. # # Format: % fixfltr [label_list] # # 24 August 2006, A.C.Raugh # $TMPFILE = "__bob.tmp"; while ($file = shift @ARGV) { open (LBL,$file) || die "Could not open $file ($!)"; open (TMP,">$TMPFILE") || die "Could not open $TMPFILE ($!)"; $line = ; while ($line !~ /^FILTER_NAME/) { print TMP $line; $line = ; } # Check for existing quotes. If found, there's nothing more to do on # this file: if ($line =~ /"/) { close(LBL); close(TMP); unlink $TMPFILE; next; } # We need to add quotes: chop $line; chop $line; $line =~ s/\s+$//; $line =~ s/= (\S+)$/= "$1"/; printf TMP "%-78.78s\r\n", $line; # Transfer the rest of the file: while (!eof(LBL)) { $line = ; print TMP $line; } # Done: close(TMP); close(LBL); rename $TMPFILE, $file; }