It's a good idea to take a look at what your variables contain when you find that your code is not working as you expect. What's in $currentlog? What is $hour? It's quite likely that the first 2 entries in @logfiles are '.' (the current directory) and '..' (the directory above the current directory). You probably don't want to open either one of those. Have a look at the filenames you are reading from "/perl/ass/" in the order that they appear in the array @logfiles:
use warnings;
use strict;
opendir(LOGS, "/perl/ass/") or die "Couldn't open /perl/ass/, $!";
my @logfiles = readdir(LOGS);
print "File: $_\n" for @logfiles;
Enabling warnings is useful, for example it would have pointed out your typo when you set $currentlog (use $logfiles[$hour] instead).
Update: Oh, Win32. Your initial code threw me off because you used '/' in your file and directory paths. I don't do enough Win32 work to help - sorry.
-
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.
|