I want to count the number of characters after I have figured out the starting point.
__DATA__
1-thisthestartingpoint
COUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINEBEFORETHENEXTSTARTINGPOINT
COUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINEBEFORETHENEXTSTARTINGPOINT
COUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINEBEFORETHENEXTSTARTINGPOINT
2-nextstartingpoint
ETCETCETCETCDONOTCOUNTTHENUMBEROFCHARACTERSPRESENTINTHISLINE
I have written the following script but it does not seem to solve the purpose. it does not go to the line whose characters are supposed to be counted, instead gives length of 1-thisisthestartpoint. Any suggestions on how count the number of characters in the line following the regex. I am new to Perl and programming in general, so kindly go easy on me.
open (FILE, "/usr/filename") || die "cant open filename";
my @body = <FILE>;
foreach $_(@body){
last if ($_=~/[2-9]-[a-z]+/);
if ($_=~ /1-[a-z]+/){
chomp ($_);
push (@value ,split (//,$_));
my $length = @value;
print @value;
print "\n the length is $length\n";
}