Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Appropriately assigning times to variables

by Win (Novice)
on May 02, 2007 at 14:58 UTC ( [id://613175]=note: print w/replies, xml ) Need Help??


in reply to Re: Appropriately assigning times to variables
in thread Appropriately assigning times to variables

I like this code because it takes out the need for a module. The wider context for the code you have given me is:
my (@priority_numbers_in_order, @directories_to_transport) = Search_di +rectories ($input_directory_C, $node); my $count = 0; for (@directories_to_transport){ my $priority_number = $priority_numbers_in_order[$count]; my $specific_recipient_directory = "$recipient_directory"."$priority +_number"; $dir = $_; opendir(DIR, "$dir") or die $!; my $file_name; while (<DIR>){ $file_name = $_; } my $dir_and_filename = $dir.$file_name; rename "$dir_and_filename", "C:$specific_recipient_directory/$file_n +ame" or warn $!; $count++; } sub Search_directories { my ($input_directory_CC, $node) = @_; my $directory_of_interest = "$input_directory_CC"; opendir (DIRY, "$directory_of_interest") or die "Error opening direc +tory : $!"; my @directories; while ($_ = (readdir DIRY)) { print $_, "\n"; if (-d "$input_directory_CC/$_") { print "This is a dir $_ \n"; if ($_ =~ /\d$/){ print "This directory is a number: $_"; push (@directories, $_); } } } close DIRY; print "\n\&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n".$input_directory_CC.@dire +ctories."\n\n"; for my $dir_num (@directories) { my @direcories_to_transport; print "\nforeach of the direcotories : $dir_num\n"; my $input_dir = $input_directory_CC.$dir_num; print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>$input_dir"; opendir DIRY, $input_dir or die "Error opening directory $input_ +dir - $!"; my @directories_time_tagged = grep /\d*$/, readdir DIRY; closedir DIRY; chomp(my @directories_time_tagged = <DATA>); for my $directory_name ( @directories_time_tagged ) { next unless $directory_name =~ /(\d\d\d\d_\d\d_\d\d_\d\d)/; # Yea +r_month_day_hour my $date_time = $1; my ($year, $month, $day, $hour) = split /_/, $date_time; my ($y_now, $m_now, $d_now, $h_now) = (localtime)[5,4,3,2]; my $now = sprintf('%d_%02d_%02d_%02d', $y_now+1900, $m_now+1, $d_n +ow, $h_now); if ($date_time le $now ) { # If the date has been passed print "\nconditions have been met for $directory_name\n"; my $directory_to_move = $input_directory_CC.$dir_num..$directory +_name; push (@direcories_to_transport, $directory_to_move); push (@priority_numbers_in_order, $dir_num); } } } return @priority_numbers_in_order, @direcories_to_transport; }
I've not tested it though.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://613175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found