shadowm

Untitled

May 12th, 2011
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.44 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. foreach my $fn (@ARGV) {
  7.     my $ofn = $fn . '.new';
  8.  
  9.     open IN, '<', $fn
  10.         or die "Cannot open " . $fn;
  11.     open OUT, '>', $ofn
  12.         or die "Cannot create " . $ofn;
  13.  
  14.     my $last_line = '';
  15.  
  16.     while(<IN>) {
  17.         s/zorder="3"/zorder="11"/
  18.             if $last_line =~ /\[water\]/;
  19.  
  20.         print OUT $_;
  21.  
  22.         $last_line = $_;
  23.     }
  24.  
  25.     close IN;
  26.     close OUT;
  27.  
  28.     rename $ofn, $fn
  29.         or die "Could not replace " . $fn;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment