----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Friday, August 26, 2005 10:37 PM
Subject: Re: Need an explanation
> maybe this is brief:
>
> while (<>) {
> chomp;
> next if /^#/;
> next if /^$/;
> my ($var1,$var2)=split /=/;
> $CONF{$var1}=$var2;
> }
>
>
>
> -----Original Message-----
> From: Binish A R <[EMAIL PROTECTED]>
> To: Perl Beginners <[email protected]>
> Sent: Fri, 26 Aug 2005 22:28:22 +0530
> Subject: Need an explanation
>
> I've a file, which has entries like the following ...
>
> IDENTIFIER1=value1;
> IDENTIFIER2=value2;
> IDENTIFIER3=value3;
>
> etc
>
> I've got to parse the above file and am using a hash to do the same ...
> Here is my code ...
>
>
> while (<>) {
> chomp;
> next if /^#/;
> next if /^$/;
> %CONF = split /=/;
> }
>
>
> But %CONF contains only the last key/value pair :-/
>
> So I had to modify the above script to
>
> while (<>) {
> chomp;
> next if /^#/;
> next if /^$/;
> $ref = [ split /=/ ];
> $CONF{$ref->[0]} = $ref->[1];
> }
>
> The above is working fine.
>
> So my question is why isn't the first code working?
> I don't want to use too many variables in my script,
> even with my second script I needed an extra variable viz $ref.
>
> Is it possible to get the job done using the first script?
>
>
>
> --
> /binish/ [Image removed]
>
#try
while (<>) {
chomp;
next if /^#/;
next if /^$/;
%conf=(%conf,split/=/) ;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>