hiddenlinux,
I still don't have a clear picture of what the end result is, so I am going to offer my advice based off the requirements you indicated earlier. Of course you might have to debug it a little, I have been away from Perl for about a month.
#!/usr/bin/perl -Tw
use strict;
my @data;
my @Files = grep { ! -d } </var/log/cr_user/*>;
while (my $file = shift @Files) {
unless (open (FILE,"$file")) {
# Tell yourself instead of deleting it
next;
{
while (<FILE>) {
my @fields = split /,/;
push @data , \@fields;
}
unlink $file;
}
foreach my $a_ref (@data) {
print "Full Name = $a_ref->[0]\n";
print "User Name = $a_ref->[1]\n";
print "Mothers = $a_ref->[2]\n";
print "Email = $a_ref->[3]\n";
print "Referral = $a_ref->[4]\n";
print "IP = $a_ref->[5]\n";
}
You could use a different data structe if you wanted. Additionally, if the data really is comma delimited then you should consider one of the CSV modules on CPAN since an imbedded comma will cause the code will not work properly.
Cheers - L~R
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.