while ( $line =~ /\controller_name,\s+(\w+)/g ) { my $fourth = $1; print "$fourth"; }
Also, this loop is rather suspect (and not just because of the rather bizarre indentation). Why not just use an if-conditional to do the extraction and printing? Then you won't be forced to use the /g modifier to keep the while-loop from running forever.
Win8 Strawberry 5.8.9.5 (32) Sat 05/22/2021 11:10:41 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings my $line = "controller_name,bist_top_ctrl\n"; if ($line =~ /controller_name,\s*(\w+)/) { my $fourth = $1; print "'$fourth' \n"; } ^Z 'bist_top_ctrl'
Give a man a fish: <%-{-{-{-<
In reply to Re: Unable to retrieve the string bist_top_ctrl from a file
by AnomalousMonk
in thread Unable to retrieve the string bist_top_ctrl from a file
by suvendra123
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |