Hello Perl community,
Once more excuse me for asking something very basic. I have a file which has 
five-digit strings. Some of the groups may contains from one to five slashes, 
as below. 
///// ///// 92765 15426 679// 28011 10660 831//

In the code below I am reading from file1, replacing every occurence of / by 9 
and rewriting the strings in file2, and deleting original file1. I am getting 
an error as "use of uninitialised value is substitution s///" indicating the 
error is on the line with "$slashes =~ s/\/{1,5}/9{1,5}/g;".

am working on Windows with Cygwin.

My reading of the literature does not yield any solution. Assistance 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 $file1 = "file1.txt";
print "file1='$file1'\n" if $debug;
my $file2 = "file2.txt";
print "file2='$file2'\n" if $debug;

    my @slashes;
    my $slashes;

    open (OUT1, "<$file1") or die "open '$file1: failed $! ($^E)";
    open (OUT2, ">$file2") or die "open '$file2: failed $! ($^E)";
        @slashes = <OUT1>;
    close OUT1;

for my $i (@slashes) {
   $slashes =~ s/\/{1,5}/9{1,5}/g;
   }

print OUT2 "@slashes";
close OUT2;

unlink $file1 or die "Failed to delede $file1: $!\n";

__END__




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

Reply via email to