Not exactly answering your question maybe…
…but since your time string is perfect for pulling the time comparison into the domain of string comparison…
use strict;
use warnings;
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)/; # Year_
+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_now
+, $h_now);
if ($date_time le $now ) { # If the date has been passed
print "\nconditions have been met for $directory_name\n";
}
}
__DATA__
foo_2006_03_02_14_verzeichnis
bar_2007_05_02_02_directory
baz_2007_05_03_22_dossier
-
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.
|