This can be made with a regular expression:
#!/usr/bin/perl
#vim: set shiftwidth=2 autoindent showmatch syntax=perl
use strict;
use warnings;
# all lines following __DATA__ go into $s
my $s;
{ local $/ = undef; $s = <DATA>; }
my %vars;
# match 1 or more alphabetics chars followed by an '=' followed by anything
# between "s or anything up to a \n
while ($s =~ /\G([[:alpha:]]+)=(?:"(.*?)"\n|(.*?)\n)/sg) {
my $k = $1;
my $v = $2? $2: $3;
$vars{$k} = [ split /\s*,\s*/s, $v ];
}
use Data::Dumper;
print Dumper(\%vars);
print "\n";
print "Value for oracleftpport is $vars{oracleftpport}[0]\n";
print "Value for ftpfiles is @{$vars{ftpfiles}}\n";
# this prints:
#$VAR1 = {
# 'password' => [
# 'password'
# ],
# 'ftpfiles' => [
# '/var/opt/file1',
# '/var/opt/file2',
# '/var/opt/file3',
# '/var/opt/file4',
# '/var/opt/file5 f/var/opt/ile6',
# '/var/opt/file7'
# ],
# 'oracleftpport' => [
# '2111'
# ],
# 'login' => [
# 'logname'
# ]
# };
#
#Value for oracleftpport is 2111
#Value for ftpfiles is /var/opt/file1 /var/opt/file2 /var/opt/file3
/var/opt/file4 /var/opt/file5 f/var/opt/ile6 /var/opt/file7
# The data
__DATA__
login=logname
password=password
ftpfiles="/var/opt/file1, /var/opt/file2, /var/opt/file3,
/var/opt/file4, /var/opt/file5 f/var/opt/ile6,
/var/opt/file7"
oracleftpport=2111
__END__
Hope it helps
Roberto
wrote:
<pre wrap>Hi,
I've just searched the web and tried the archives but I'm not in luck
I'm reading a parameter file:
PARAM=value
PARAM1=value2
Etc. and this works great, but all of a sudden...I need multiple lines..
For example:
login=logname
password=password
ftpfiles="/var/opt/file1, /var/opt/file2, /var/opt/file3
/var/opt/file4, /var/opt/file5 f/var/opt/ile6,
/var/opt/file7"
oracleftpport=2111
The file names are relative and so quite long so I prefer to put one
on each line ?
I've thought of slurping in paragraph mode but I'm really stuck for a
good way to do it..
Perhaps a module ?
Any ideas ?
I can do this any other way, I just need to pass these parameters, I
can do it any way I want..
I prefer not having two parameter files but ...
Thanks in advance,
Jerry
</pre></body>
</html>
</html>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>