Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Enter Perl's English-like syntax:
# "if..." if ( # the number of details records $details_record_count # does not tally with (is not equal to) != # the count given in the total count fie +ld at the end of the file # (we'll assume you've read the file and + have it already) $total_count) # then { # 1.1 Reject the file push @rejected_files, @filename; # 1.2 Record error details in the error log print $error_log "$file total count field does not agree ($details +_record_count actual, $total_count in file)\n"; }
Most of the time Perl does a really good job of expressing things in very close to the original English statement. Note that I've left out the reading of the file, extraction of the count, and setup of the error log, because I'm giving you the opportunity to learn how to do that part. Note also that you'll need to print the rejects at the bottom of your program (hint: join("\n",@rejected_files)). I'm providing this to encourage you to go ahead and try stuff and see if it works (writing tests for your program will help with this) because Perl really is very close to a natural language in terms of expressing things. Let's pull those comments out and see how it reads without them:
# if the number of actual detail records doesn't match the count in th +e file, mark this file as rejected and print a message to the error l +og. if ( $details_record_count != $total_count) { push @rejected_files, @filename; print $error_log "$file total count field does not agree ($details +_record_count actual, $total_count in file)\n"; }
See? Not hard at all! You can do it. Go ahead and put the comments in to help you think it out if necessary. You can always remove or shorten them when you're done. (Use a revision control system; it'll save you incredible amounts of work.)

In reply to Re: pls help in perl by pemungkah
in thread pls help in perl by sandhya

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (7)
    As of 2014-12-21 22:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (108 votes), past polls