Hi folks! Well, just to sum it up, how I finished this one off:
my %config; my ($parameter, @value); open(TEMP,'</tmp/Config') || die "cannot open temporary file for output!! : $!"; local $/; $contents = <TEMP>; close TEMP; $contents =~ s/\\\n//g; # put everything on one line (deletes \ followed by # newline) foreach (split /\n/, $contents){ if($_ =~ m/^Adm.Components=/) { if(/=/) { ($parameter, my $tmp) = split(/=/); @value = split(' ',$tmp); }else{ @value = split(' '); } push(@{$config{$parameter}}, @value); print CONFIG "$parameter has the following components:\n\n"; foreach $i (@value) { print CONFIG "$i\n"; } # END of foreach } # END of if statement } # END of foreach statement } # END components function This is snipped, relevant code for what I'm trying to do. CONFIG is a filehandle for my output file, where I'm gathering more data than just this.. ;) I have a feeling that there will be takers for optimising this as well, so enlighten me if you wish.... Thanks for the help!! Best Regards Anders Holm Critical Path Technical Support Engineer ---------------------------------------------------------------------- Tel USA/Canada: 1 800 353 8437 Tel Worldwide: +1 801 736 0806 E-mail: [EMAIL PROTECTED] Internet: http://support.cp.net -----Original Message----- From: drieux [mailto:[EMAIL PROTECTED]] Sent: 11 June 2002 16:15 To: Anders Holm Cc: Beginners Perl Subject: Re: Putting values into hash On Tuesday, June 11, 2002, at 06:39 , Anders Holm wrote: [..] > I'm parsing a configuration file for an application, and it has a > parameter > as such: > > Parameter=Value1 Value2 Value3 \ > Value4 Value5 Value6 \ > Value7 Value8 > > There are other parameters before and after this entry in the > configuration > file as well. I want to grab these values and put them in an array, so I > can > later use them for additional usage. I'm just not getting this anywhere. > And > I don't even have a code snippet to show, since I'm not sure how to > iterate > over these lines either. NB. there is a newline after each \, hence why it > doesn't just read them all in as one line... :( [..] http://www.wetware.com/drieux/pbl/perlTrick/AnotherConfigReader.txt here I parse them all - let God Choose the loosers, and if you want the array with that specific key then you would ask for @{$config{'Parameter'}} enjoy... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]