|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting data into an array from config-file?
Hi,
i do have a config-file with various single variables like: $config{'name'} = "name"; $config{'city'} = "city"; and all works fine. Now i need to enter more than one value into such a var like: $config{'domains'} = "'yahoo.com','hotmail.com'"; If i use this hardcoded like: my @domains = ('yahoo.com','hotmail.com'); everything works but if i use my @domains = ($config{'domains'}); it fails ... Where's my fault? |
|
#2
|
||||
|
||||
|
Re: Getting data into an array from config-file?
Quote:
Need to make a few changes. In your config file change this: $config{'domains'} = "'yahoo.com','hotmail.com'"; to this: $config{'domains'} = ['yahoo.com','hotmail.com']; then you can call you domains by for my $domain (@{$config{'domains'}}) { # do something here with each $domain } or my @domain = @{$config{'domains'}}; but not necessary, arrays tend to use alot of resources if the array is large.. stores everything in direct memory. this is know as referencing, works well for hash/array referencing. Hope this helps ![]() Mickalo
__________________
Thunder Rain Internet Publishing Custom Programming & Database development Providing Personal/Business Internet Solutions that work! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Getting data into an array from config-file? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|