J
justme
hi
i have a text file with some info like this:
[local]
/home/user
[files]
test1.txt
test1.htm
[dest]
/home/dest
[server]
127.0.0.1
[end]
[local]
/home/user1
[files]
test1.dat
test2.txt
[dest]
/home/dest1
[server]
127.0.0.1
[end]
Actually i am doing an ftp configuration file where the perl sript
will go through this file and pick up the definitions between [local]
and [end]
and then using Net::FTP module to transfer files from local directory
to destination at server defined by [server] until [end] and then
start transferring the next section from [local] to [end]
Am i going the correct way by doing the incomplete code below ? If not
any better way to do that...thanks
while(<FILE>)
{
if (/\[local\]/ .. /\[files\]/ ) {
next if ( $_ =~ /\[local\]/ or $_ =~ /\[files\]/ ) ;
$localdir = $_; #get the line after [local]
}
if ( /\[files\]/ .. /\[dest\]/ )
{
print "files = $_\n";
next if ( $_ =~ /\[files\]/ or $_ =~ /\[dest\]/ );
push(@files, "$_");
}
if (/\[dest\]/ .. /\[server\]/ )
{
next if ( /\[dest\]/ or $_ =~ /\[server\]/ );
$dest = $_; #get dest directory to put @files
}
.....
......
}
print "local is $localdir\n";
print "files are = @files\n";
print "dest is = $dest\n";
i have a text file with some info like this:
[local]
/home/user
[files]
test1.txt
test1.htm
[dest]
/home/dest
[server]
127.0.0.1
[end]
[local]
/home/user1
[files]
test1.dat
test2.txt
[dest]
/home/dest1
[server]
127.0.0.1
[end]
Actually i am doing an ftp configuration file where the perl sript
will go through this file and pick up the definitions between [local]
and [end]
and then using Net::FTP module to transfer files from local directory
to destination at server defined by [server] until [end] and then
start transferring the next section from [local] to [end]
Am i going the correct way by doing the incomplete code below ? If not
any better way to do that...thanks
while(<FILE>)
{
if (/\[local\]/ .. /\[files\]/ ) {
next if ( $_ =~ /\[local\]/ or $_ =~ /\[files\]/ ) ;
$localdir = $_; #get the line after [local]
}
if ( /\[files\]/ .. /\[dest\]/ )
{
print "files = $_\n";
next if ( $_ =~ /\[files\]/ or $_ =~ /\[dest\]/ );
push(@files, "$_");
}
if (/\[dest\]/ .. /\[server\]/ )
{
next if ( /\[dest\]/ or $_ =~ /\[server\]/ );
$dest = $_; #get dest directory to put @files
}
.....
......
}
print "local is $localdir\n";
print "files are = @files\n";
print "dest is = $dest\n";