Re: What config file for a .pm perl module ?
On Fri, Dec 28, 2001 at 10:31:01AM +1100, Craig Sanders wrote:
> On Thu, Dec 27, 2001 at 07:03:38PM +0100, Eric Van Buggenhaut wrote:
[...]
>
> my %virtual1 = {};
>
> while (<>) {
> chomp ;
> s/#.*//; # strip comments
> s/^\s*|\s*$//g; # strip leading & trailing spaces
> next if (/^$/); # ignore blank lines (incl. comments)
> my @line = split /\|/ ;
>
> # do whatever you need with @line
> # $line[0] = hostname
> # $line[1] = username
> # $line[2] = password
> # ...
> # $line[8] = dbhost
> foreach(1..8) { # loop from $fields[1]..$fields[8]
> $virtual1->{$line[0]}->{$fields[$_]} = $line[$_] ;
> } ;
>
> };
> close(IN);
>
> you can verify that this does what you want by using the Data::Dumper
> module. e.g. by adding something like the following lines to the script:
>
> use Data::Dumper ;
> print $Dumper($virtual1);
print Dumper($virtula1);
I spent some time try to understand why it was failing ;)
Thanks for your help anyway, your code works fine here and I learnt a
lot about references and structures today !
Cheers,
--
Eric VAN BUGGENHAUT "Hay tampones y tampones ..."
(Eva Serrano)
\_|_/ Andago
\/ \/ Av. Santa Engracia, 54
a n d a g o |-- E-28010 Madrid - tfno:+34(91)2041100
/\___/\ http://www.andago.com
/ | \ "Innovando en Internet"
eric@andago.com
Reply to: