- 論壇徽章:
- 0
|
請(qǐng)教各位大俠:- #!/usr/bin/perl -w
- use strict;
- sub read_file
- {
- my (%conf_hash);
- open(CONFFILE, "1.conf") || die "connot open 1.conf: $!";
- while (<CONFFILE>) {
- next if (m/^[ \t]*$/);
- chomp;
- s/#.*//;
- s/^[\b\t]+//;
- %conf_hash = ( %conf_hash, split(/=/) );
- }
- return %conf_hash;
- }
- my %conf = read_file();
- my $man = "$conf{man}";
- my @man2 = $man;
- foreach (@man2)
- {
- print "$_\n";
- }
復(fù)制代碼 ----------------------------------------------------
$ ./1.pl
$ "張三","李四","王五"
$ cat 1.conf ###配置文件
#配置文件
man="張三","李四","王五"
----------------------------------------------------
請(qǐng)問有沒有辦法將從配置文件讀出來的內(nèi)容 賦予給一個(gè)數(shù)組呢?或以數(shù)組形式展現(xiàn)。謝謝 |
|