[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Counting lines in a document opened in Append mode.



First, I'd like to thank the people that responded to my last message about
counting the number of lines in a document. I haven't quite solved the
problem yet though. One method I was given works when I open the document
in write mode, but not when I open it in append mode. Here's some of my
code (please don't laugh! :-)

You can skip down to the two areas I have commented out.

      if ( open (QUEUEDATAFILE, ">>" . $queue_file_path) ) {
         @queuedatafile = (<QUEUEDATAFILE>);
         if ( open (QUEUEFRAMEFILE, ">" . $html_queueframe_path) ) {

            &MIME_header ("text/html", "Queue Data", "ticketDisplayFrame");
    
            print "<PRE>", "\n";
            print "this is a confirmation of success", "\n";
            print "option = ", $option, "\n";
            print "calltaker = ", $calltaker, "\n";
            print "os = ", $os, "\n";
            print "application = ", $application, "\n";
            print "machinetype = ", $machinetype, "\n";
            print "ldev = ", $ldev, "\n";
            print "location = ", $location, "\n";
            print "caller = ", $caller, "\n";
            print "phonenumber = ", $phonenumber, "\n";
            print "problem = ", $problem, "\n";
            print "resolution = ", $resolution, "\n";
            print "opened on: ", $date_time, "\n";

 #this method works when I open $queue_file_path in write mode, but not
 #when I open it in append mode (it always reports it as having 0 lines), 
 #like I have shown in this example.
            print "File $queue_file_path contains ", 
                   ($#queuedatafile + (1 - $[)), " lines\n";

 #this method always reports 0 lines. Not too sure of what I'm doing here.
            undef $/;
            $myfile = <QUEUEDATAFILE>;
            $thecount = ($myfile =~ tr/\n//);
            print "or ", $thecount, " lines\n";


            print "</PRE>";
            print "</HTML>";

            print QUEUEDATAFILE "$calltaker", "$sep", "$os", "$sep", 
                                "$application", "$sep", "$machinetype", 
                                "$sep", "$ldev", "$sep", "$location", 
                                "$sep", "$caller", "$sep", "$phonenumber", 
                                "$sep", "$problem", "$sep", "$resolution", 
                                "$sep", "$date_time", "\n";
            close QUEUEFRAMEFILE;
            close QUEUEDATAFILE;



Again, thanks, and I hope you can help me out on this one.
rob

---------------------------------------------------
This message was created and sent using the Cyberdog Mail System
---------------------------------------------------