Hi All, My apologies for not being here for a while. Thank you all for showing me directions to my concerns. i will now share snippet of my code (which is not working yet). As of now i have five lines in the text file, wherein each perl process has to execute only one line upon meeting the conditions i.e "it should match the line which has the word pending". P.S Somehow when i post this script all the indentation vanishes.apologies for that. My script
use Fcntl qw(:flock :seek); my $myfile = "C:\\ssk\\A.txt"; open(MYFILE, $myfile) or die; undef $/; flock(MYFILE, 1); foreach my $line (<MYFILE>) { $line =~ /(\w*):(\w*):(\w*)/g; my $status = $3; if (($3 ne "done") || ($status ne "inprogress")) { # do nothing } } close MYFILE; open(MYFILE, "+< $myfile") || die; flock(MYFILE, 2); my @content = <MYFILE>; my $inprogress = "inprogress"; foreach my $line (@content) { $line =~ m/(\w*):(\w*):(\w*)/; if ($3 eq "pending") { $line=~ s/pending/inprogress/; seek(MYFILE, 0, SEEK_END); print MYFILE "$line"; splice(@content,0,1); } } close MYFILE; Contents of text file ===================== cmd:doscommand1:pending cmd:doscommand2:pending cmd:doscommand3:pending cmd:doscommand4:pending cmd:doscommand5:pending

Please let me know if i am on the right track, since the script is not working yet.. Do i still need to go ahead with DBMS.

thanks Sachu


In reply to Re^2: Multiple Acess to a single file by sachu
in thread Multiple Acess to a single file by sachu

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.