Please Help
I have multiple folders want to read trough each folder and search for certian file. I have code which is working fine but does not do what I want. I dont want to hard code path as it read different folder within
sub get_phone_log {
#------------------------------------------------------------------------------------------
$p_dir="D:/43895" ;
print $p_dir;
opendir(DIR, "$p_dir") or die "cant open directory: $!\n";
while(defined($folder = readdir(DIR))) {
if (length $folder > 5)
{
print $folder;
}
if (substr($folder,0,8) eq 'PHONELOG') {
&print_out_contents;
}
}
closedir(DIR) ;
#------------------------------------------------------------------------------------------
}
sub print_out_contents {
#------------------------------------------------------------------------------------------
my $phonelog = "$p_dir/$folder";
open (P1FILE, "$phonelog") or die "can't open $phonelog: $!";
flock (P1FILE, LOCK_SH) or die "can't lock $phonelog: $!";
while (<P1FILE>)
{
chomp;
@linex = split(/\|/);
&plfields;
&build_days;
}
close (P1FILE);
#------------------------------------------------------------------------------------------
}
#------------------------------------------------------------------------------------------
sub plfields {
#------------------------------------------------------------------------------------------
$plcallername = $linex[0];
$plcallerphone = $linex[1];
$plcalleremail = $linex[2];
$plsentdate = $linex[3];
$plsentdate_ccyy = substr($plsentdate,0,4) ;
$plsentdate_yy = substr($plsentdate,2,2) ;
$plsentdate_mm = substr($plsentdate,4,2) ;
$plsentdate_dd = substr($plsentdate,6,2) ;
$pltime = $linex[4];
$plfilebase = $linex[5];
$pltext = $linex[6];
($plfilebase_type,$plfilebase_num,$plfilebase_name) = split (/\_/, $plfilebase);
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/