anushenoy
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
you can also use range operators to solve this problem
my $read = "a.txt";
my $write = "a_modified.txt";
open(READ,"<$read");
open(WRITE,">$write");
while(<READ>) {
chomp $_;
my @arr = split(//,$_);
if (scalar(@arr)>= 80) {
print WRITE @arr[0 ..79],"\\"."\n";
print WRITE @arr[80 .. $#arr],"\n";
} else {
print WRITE "$_\n";
}
}
close READ;
close WRITE;
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
you can try this:
- anushenoy May 14, 2016