rohit_raghu has asked for the wisdom of the Perl Monks concerning the following question:
This is the output I get:#!usr/bin/perl use strict; open (FILE,'<abc.txt'); my %config; while(<FILE>) { if($_=~'^(\w+_?\w+)=([01])') { $config{$1}=$2; print "$1:$config{$1}\n"; } } close FILE; for my $i (sort keys(%config)) { print "$i:$config{i}\n"; }
And this is the sample input file:$ perl test002.pl AAA:1 BBBB:0 CCC:0 DD:1 AAA: BBBB: CCC: DD:
AAA=1; BBBB=0; CCC=0; DD=1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash assignment
by Ratazong (Monsignor) on Jul 25, 2012 at 07:43 UTC | |
by rohit_raghu (Acolyte) on Jul 25, 2012 at 07:46 UTC | |
by ww (Archbishop) on Jul 25, 2012 at 12:06 UTC |