Monks,
I am working on a task to parse the logfiles which are in side the latest directories.
Bellow is the code i have written to open the latest logfile,for this i predeclared the path to get the directory list.
#!/usr/bin/perl
$arg=$ARGV[0];
$pattern="build.log";
$path="/remote/scm/rsync/builds/$arg/FailedInformal";
#print "$path\n";
@releases=`ls -1 $path`;
#print "@releases\n";
$x=0;
foreach $file(@releases)
{
if($file=~/^\d/)
{
$dlist[$x]=$file;
}
$x++;
}
#print "@dlist\n";
@three=@dlist[-1,-2,-3];
#print "@three\n";
$latest=$three[0];
print "$latest\n";
$path1="$path/$latest";
print "$path1\n";
@logs=`ls $path1`;
#print "@logs\n";
#print "$logs[1]\n";
#print "$path1/@logs[1]";
$p=
open(F,"$path1/build.log")or die "$!\n";
while(<F>) {
chomp;
print "$_\n";
}
3.0.0.0.118
3.0.0.0.113
3.0.0.0.111
3.0.0.0.118
/remote/scm/rsync/builds/v_dialer/FailedInformal/3.0.0.0.118
No such file or directory
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.