perl --> printing characters in between the multiple metacharacters present in a single line
- 阅读更多 关于 perl --> printing characters in between the multiple metacharacters present in a single line
问题 I am trying a script to find out the characters between the metacharacter "|". I tried to get the position of the first and the succeeding "|" metacharacter and tried to print the string between those two positions. Below is the code I tried: File : | A| B| Count| D| E| Expected output : A B Count D E if($line =~ /\|/) { while ($line =~ m/\|/g) { my $start_pos = $-[0]; my $end_pos = $+[0]; my $hit_pos = "$start_pos - $end_pos"; my $char = substr($line, $start_pos, $end_pos); if($char =~/\w/){