Once more Dear kind Perl users, I have a small problem, being so raw in perl. I 
have binary files which contain some headers of the type nx 70 ny 1, and nxny 
3542 ny 1.
I want to replace all ocurrences of nx by 71, ny by 71 and nxny by 5041.
The code below does not give any error but I end up with files of size 0 and 
the same zero size files are copied to current directory where the scrip is 
located.
Help will be appreciated.
Zilore

#!/usr/bin/perl --

use strict;
use warnings;
use POSIX;
use File::Path;
use File::Copy;

# Variable declaration
my $debug = 1;

my $Grib_dir = "grib_files";

    my @slashes;
    my $slashes;

opendir DIR, $Grib_dir or die "opendir failed on $Grib_dir: $! ($^E)";
while ( my $item = readdir DIR ) {
    next if -d $item;
    # Extra filtering, to copy only grib files ending in H
    next unless $item =~ /\*H$/;

    open (IN, "+>$item") or die "open '$item': $! ($^E)";
    binmode IN;

    @slashes = <IN>;

    for my $i (@slashes) {
        s/nx d{4} {ny 1}/{nx 71 ny 71}/g;
        s/nxny {4}{ny 1}/{nxny 5041}/g;
       }
      print IN "@slashes";
      close IN;
}
closedir DIR;




      
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to