I have a PERL script that does some search operation and i keep writing stuff to a log file. I have used this pattern in a LOT of PERL scripts but unfortunately, this time it just won't work!!!! it's a very simple PERL statmenet - why won't it work?!!!

#!/usr/bin/perl use strict; # use warnings; use XML::LibXML; use Spreadsheet::ParseExcel; use Spreadsheet::WriteExcel; use File::Copy; use File::Glob ':glob'; use Data::Dumper; my $paramcount = scalar @ARGV; if ( 0 == $paramcount || $paramcount < 3) { print "Usage: perl hunt.pl <excel sheet> <search folder> <output f +older>\n\n"; exit; } my $i_sheet = $ARGV[0]; my $search_folder = $ARGV[1]; my $out_folder = $ARGV[2]; # sanity check and preparation.... unless ( -d $search_folder ) { print "Input folder does not exist \n"; exit; } unless ( -f $i_sheet ) { print "Input excel does not exist \n"; exit; } unless ( -d $out_folder ) { print "Out folder does not exist \n"; exit; } # prepare log file... open( LOG, ">> huntlog.log") || die("Could not open log file!"); print LOG "Log start... \n";


The last line in this code snippet and any line that starts with "print LOG ..." would not work - the log file gets created but it remains empty forever!!

Any idea why?



In reply to writing to a log file.... by biswanath_c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.