I dont know if this will be of much help, but i worked for me and prints "Date of Last Update: 10/15/2013".

But but you may have to do a work around unless the dates are always displayed as "01/01/2014" (10 characters), if its "1/1/2014" (8 characters)then you will have to modify the pattern matches position like "@-"+1, and then read one less character as well. which should print " Date of Last Update: 1/1/2014"
use File::Slurp; my $file = read_file( "file.rtf" ); $match = "Date of Last Update: "; if ($file =~ /$match/){ open my $file, "<", "file.rtf"; my $startpos = "@-"+2; #if date is 8 chars then change to "@-"+1 seek $file, $startpos, 0; read $file, my $calender_date, 31; #if date is 8 chars change to 30 print $calender_date; }
And im not sure about the signatures, but hopefully the above will be helpful :)

You can also return the position in which the match happens with @- for beginning of the match or @+ for the end of the match.


nevermind the above <.<
here is working code that will get the exact info you want.
use File::Slurp; my $file = read_file( "1.rtf" ); $match0 = "Date of Last Update: "; $match1 = "Sign-Off Approvals"; $match2 = "Jane Doe, CEO"; if ($file =~ /$match0/){ open my $file, "<", "1.rtf"; my $startpos0 = "@-"; seek $file, $startpos0 +2, 0; read $file, my $calender_date, 29; if ($calender_date =~ /\\/){ seek $file, $startpos0 +2, 0; read $file, my $calender_date, 31; print "\n"; print "$calender_date\n\n"; } else { print "\n"; print "$calender_date\n\n"; } } if ($file =~ /$match1/){ open my $file, "<", "1.rtf"; my $startpos1 = "@+"; seek $file, $startpos1 +42, 0; read $file, my $first_sig, 66; print "$first_sig\n"; print "Jane Doe\n\n"; } if ($file =~ /$match2/){ open my $file, "<", "1.rtf"; my $startpos2 = "@+"; seek $file, $startpos2 +82, 0; read $file, my $second_sig, 67; print "$second_sig\n"; print "John Doe\n\n"; } prints: C:\Users\guy\Desktop\tests>test.pl Date of Last Update: 10/15/2013 ______________________________________________________/_____/_____ Jane Doe ______________________________________________________/_____/_____ John Doe
This simply just pattern matches then seeks from the match.

You should also be able to do something like
if (first_sig = "_____________________________________________________ +_/_____/_____"){ print "There is no first signature"; } else{ print "Document has a first signature"; } if (second_sig = "____________________________________________________ +__/_____/_____"){ print "There is no second signature\n"; } else{ print "Document has a second signature\n"; }
this also includes if your date is only 8 characters eg: 1/1/2013. if not, then dont worry about it.
this is also based off of the example you provided and will only work if every rtf file your editing is formatted identical to it. also fyi, if you open this or any document in a hex editor, you will see the formatting of the file, and can manually parse it to get whatever data you want.

In reply to Re: How can I find a line in a RTF file? by james28909
in thread How can I find a line in a RTF file? by kevyt

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.