Good evening Monks,
I have not been able to solve this riddle in about 8 hours either online or with The Camel, but I am so close..
I have two files that I have to compare. The first is a list of clients stored in clientlist.txt. The second is a huge list of all backed up clients with things like backup times (one line with each client and extra info seperated by commas)named client_last_backup.csv. All that I want to do is open the list of clients and the "clb.csv" and whenever a client in the client list is found in the csv, write that line to a new csv. I can only my loop to run once but the clients will all print if a throw a print $client just after the 2nd while. Here is my code:
open(clients, "<clientlist.txt") || die "Can't open clients: $!\n";
open(file_compare, "<client_last_backup.csv") || die "Can't open file_
+compare: $!\n";
open(CSV_OUT, "> lastbackup.csv") || die "Unable to open lastbackup.cs
+v: $!";
print CSV_OUT "SERVER,CLIENT,LAST SUCCESSFUL FULL,LAST SUCCESSFUL INCR
+,LAST ATTEMPT\n";
my @clients = "";
LOOKUP: while(<clients>)
{
@clients = $_;
$client = shift @clients;
chomp $client;
CLIENTS: while (<file_compare> )
{
if (m/$client/)
{
print CSV_OUT "$_";
}
#print CSV_OUT "$client";
}
Thank you so much for having a look!
Urbs
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.