you've had a few suggestions on way to rewrite your code, but it might be useful to have a quick look at what you were doing wrong.
Yep... actually, that would be quite useful... I am still learining the ways, and doing it slowly unfortunately, as the need to pay the bills is overriding the desire to learn new skills... sigh... I miss my old job. ;)
foreach (@lines) {
my($month, $day, $time, $data1, $data2) = split / /;
open(NEWTIME, $time);
Here you've tried to open a file which has the name $time. I strongly suspect that this file doesn't exist. Checking the return value from open would have told you this.
Ahhh... the idea was (misguided to say the least) an attempt to open a filehandle using the contents of $time. obviously that was wrong...
while (<NEWTIME>) {
Having opened a file that doesn't exist, you proceed to try and read from it. If you had use warnings turned on, you would have been warned at this point. However, as the file doesn't exist is is effectively empty and <NEWTIME> won't return any data so the code in the while loop never gets executed.
Yes... sigh... I know better than that as well... I should always have the -w switch on, but for somereason it completely slipped me when I started this lil project.
select NEWLOG;
print "$time2\n";
It looks like you're selecting a filehandle that hasn't been opened.
open NEWLOG, ">>foofinal.txt";
}
Once more, you should check the return code from open.
I dont remember why it is I had the open after the select statement... I borrowed this code from another script I had been working on months ago and had stopped working on for one reason or another... at that point, I was trying to get my way through the Llama book during my lunch breaks at work, while also trying to do some "real world" problems to help learn more...
Thank you tho for the guidance on what was happening. As stated earlier, I am still much a beginner, and have MUCH left to learn. And this is all much more difficult to do when you have had no formal or even informal training, and all the training you do have is garnered a few minutes here, and a few minutes there... hehe... I feel kinda silly now...
and to be honest, this all started because I cant find my sed/awk pocket ref, so I figured it would be fun to try to do it in perl instead... heheeh... Now I have the answer in both perl and bash.
Thanks again!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.