#!/usr/bin/perl # Routine to change "MAGE_NAME" to "IMAGE_NAME" in the "centers" file labels. # # Recurses down through current working directory. # # Format: fixmage # #============================================================================== use File::Find; # Run: find({wanted => \&fixit},"."); # That's it for the main routine. #------------------------------------------------------------------------------ sub fixit # Routine to fix the "MAGE_NAME" column name in the *centers.lbl files. # We are cd'ed to the local directory when this routine runs. { my ($filename, $line); my $TMPFILE = "zzzTMP"; $filename = $_; return if ($filename !~ /^.*centers\.lbl$/); # Open files: open(OLD,"varlen -rmcr $filename |") || die "Could not open $File::Find::name pipe for reading ($!)."; open(NEW,"| fixlen -c > $TMPFILE") || die "Could not open $File::Find::dir/$TMPFILE pipe for writing ($!)."; # Loop through the label, looking for the "MAGE_NAME" line to correct: while ($line = ) { $line =~ s/"MAGE_NAME"/"IMAGE_NAME"/; printf NEW $line; } close(OLD); close(NEW); rename $TMPFILE, $filename; return; }