Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re^2: Appropriately assigning times to variables by Win
in thread Appropriately assigning times to variables by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found