suvendra123 has asked for the wisdom of the Perl Monks concerning the following question:
I have a file abc.txt which contains below three lines
parameter,value
controller_name,bist_top_ctrl
support_18n,yes
I want to extract the string bist_top_ctrl
from this file
My code is below xyz.pl
use strict; use warnings; open(my $in, '<', $ARGV[0]) or die "Unable to open for read: $!"; while (my $line = <$in>) { while ( $line =~ /\controller_name,\s+(\w+)/g ) { my $fourth = $1; print "$fourth"; } } close $in;
Command to run :- perl xyz.pl abc.txt
I am not getting the string "bist_top_ctrl" at output
Where is the mistake ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Unable to retrieve the string bist_top_ctrl from a file
by jo37 (Curate) on May 22, 2021 at 13:18 UTC | |
Re: Unable to retrieve the string bist_top_ctrl from a file
by kcott (Archbishop) on May 22, 2021 at 14:28 UTC | |
Re: Unable to retrieve the string bist_top_ctrl from a file
by AnomalousMonk (Archbishop) on May 22, 2021 at 15:24 UTC | |
Re: Unable to retrieve the string bist_top_ctrl from a file
by hrcerq (Monk) on May 22, 2021 at 15:55 UTC |