I am trying to Remove the first word for each lines from a text file. Here is the code I am trying with-
use strict;
use warnings;
open(my $in, '<', 'input.txt')
or die "Cannot open input.txt: $!";
open(my $out, '>', 'output.txt')
or die "Cannot open output.txt: $!";
while (<$in>) {
print $out $_ while s/^\s*\S+\s*//;
}
close($out);
close($in);
input.txt
The person who asked.
can mark one answer.
as "accepted".
Accepting doesn't mean.
it's the best answer,
it just means that it.
worked for the person.
who asked.
however output.txt shows-
person who asked.
who asked.
asked.
mark one answer.
one answer.
answer.
"accepted".
doesn't mean.
mean.
the best answer,
best answer,
answer,
just means that it.
means that it.
that it.
it.
for the person.
the person.
person.
asked.
I just want to remove the first word for each lines, but it's looping. Any suggestion?