Below is the script is created to find a missing file in two directories and copy it to the directory i specify.. It works 100% good..but i just wanted to know if i have put the script in the right way.. Thanks!!
use File::Copy; use Date::Manip; my $search_in="U:\\Temp"; my $search_local="D:\\my"; my $copy_to=$ARGV[1]; $db_name=$db_date=$ARGV[0]; #$db_name=$db_date=$_; $db_name =~ s/\d|\.trn|\_backup_//g; $db_date =~s/[^\d]//g; $miss_file_date = UnixDate(DateCalc(ParseDate($db_date), "-10 minutes" +), "%Q%H%M"); $missing_file=$db_name."_backup_".$miss_file_date.".trn"; print "\n\nThe database name is: $db_name\n"; print "Error occured in file[input file] :$ARGV[0] \n"; print "File missing for date: $miss_file_date\n"; print "\nThe missing file is: $missing_file\n\n"; print "Searching..please wait\n"; foreach( glob("$search_local/$missing_file") ){ if (-e $_) { #$copy_to="F:\\Backup\\$db_name\\CURR" copy ($_,$copy_to) or print "Can't copy file to $curr_folder\n" and di +e; print "\nFile found!!\n"; print "File found in $search_local\n"; print "\nThe missing file $missing_file is copied to $copy_to\n"; } else{ print "local search \n"; print "Unable to find the missing file $_\n"; print "Search in sql\n"; goto search2; } } search2: foreach( glob("$search_in/$missing_file") ){ if (-e $_) { #$copy_to="F:\\Backup\\$db_name\\CURR" copy ($_,$copy_to) or print "Can't copy file to $curr_folder\n" and di +e; print "\nFile found!!\n"; print "File found in $search_in\n"; print "\nThe missing file $missing_file is copied to $copy_to\n"; } else{ print "Unable to find the missing file $_\n"; } }

In reply to Search for a missing file..iss my script correct? by sudharsan501

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.