- 论坛徽章:
- 0
|
请教各位大侠:- #!/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";
- }
复制代码 ----------------------------------------------------
$ ./1.pl
$ "张三","李四","王五"
$ cat 1.conf ###配置文件
#配置文件
man="张三","李四","王五"
----------------------------------------------------
请问有没有办法将从配置文件读出来的内容 赋予给一个数组呢?或以数组形式展现。谢谢 |
|