1849374 Members
6802 Online
104044 Solutions
New Discussion

Perl script question

 
Anthony khan
Frequent Advisor

Perl script question

Hi everyone,

I need to do some modification in perl script here's the syntex

if ($ftpid eq "zzz"){
foreach $file (@{$ftpFileL{$ftpid}}){
$basename = basename($file);
copy($file,"./$basename.$mydate[4]$mydate[3]$mydate[5]");
}
}

Right now we are putting the time stamp on each file but for 4 specific files we don't want to put time stamp and for other we want. So can someone help me out here.


Thanks
2 REPLIES 2
Mark Grant
Honored Contributor

Re: Perl script question

Why not keep a hash of filenames instead of an array and then just delete the ones you dont want to process.

Load you hash with $filename{$file}=$file;

delete them with something like delete $filename{myfile1};delete $filename{myfile2} etc;

go through them with

foreach $hashfile ( keys %filenames){
do something with $hashfile which is the name of the file
}

Just a thought
Never preceed any demonstration with anything more predictive than "watch this"
Steven E. Protter
Exalted Contributor

Re: Perl script question

Slight change will do the job:

if ($ftpid eq "zzz"){
foreach $file (@{$ftpFileL{$ftpid}}){
$basename = basename($file);
$filename = "./$basename"

if ( condition for these 4 files){
else
$filename = "./$filename.$mydate[4]$mydate[3]$mydate[5]");
}
copy($file,"$filename");
}
}


You will have to play a bit to get it to work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com