Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl TK script that parses 2 input files, comparing field by field. It identifies differences, tags them to print in a different color, and inserts them into a textbox identified by the particular record type. This process can be very time consuming depending on the size of the output. I currently save and reload data that is already processed by building the data into an array, and dumping the array to a file - the reload reprocesses the dumped array (which can take almost as much time as the original run).

Does Perl or TK have a method to save the current state of a program/display and just reload it into memory rather than reprocess the save file?
  • Comment on Reloading calculated data into TK widgets

Replies are listed 'Best First'.
Re: Reloading calculated data into TK widgets
by Courage (Parson) on Oct 01, 2002 at 15:54 UTC
    Having Tk under consideration, this is very widget-dependent

    For example, Tk::Text widget has method dump which may help you with your task.

    I think you probably should use Storable and Data::Dumper to save your variables.

    Courage, the Cowardly Dog

      Thank you courage - can you direct me to the doc on the text::dump method? I can't locate it on CPAN or with perldoc.

      Michael
        run a command "perldoc Tk::Text" and find dump method there.
      I've got the Dumper implemented now - just getting garbage (how to reload - not really mentioned anywhere...) out of it.

      $VAR1 = [ 'HEADER_RECORD' ]; $VAR2 = [ 'mark', 'current', '1.0', 'text', ' CHR_RECORD_TYPE | CHR_AB_TYPE_CODE | CHR_AIRBILL_NUMBER | +CHR_ORIG_STA_NUM | CHR_DEST_STA_NUM | CHR_SGMT_ TYPE | CHR_BILL_TO_NUMBER | CHR_BILL_TO_LEGAL_ENTITY | CHR_BILLING_STA +TUS | CHR_SELECT_JOURNAL | CHR_ENTRY_TYPE | CHR _INVOICE_DATE | CHR_INVOICE_NUMBER | CHR_CURR_CD | CHR_AIRBILL_AMT_DUE + | CHR_SHIP_DATE | CHR_INV_CLOSING_DATE | CHR_B ILLING_CYCLE_DUTY | CHR_AWB_SEQ_NO | CHR_COMBINED_DT_CODE | CHR_PASTDU +E_INVOICE_NO | CHR_CHRG_CTR | CHR_CHRG_CODE_1 | CHR_CHG_RECORD_STATUS_1 | CHR_CHG_TRAN_LVL_IND_1 | CHR_CHG_TRAN_SEQ_N +O_1 | CHR_CHRG_CODE_2 | CHR_CHG_RECORD_STATUS_2 | CHR_CHG_TRAN_LVL_IND_2 | CHR_CHG_TRAN_SEQ_NO_2 | CHR_CHRG_CODE_3 | +CHR_CHG_RECORD_STATUS_3 | CHR_CHG_TRAN_LVL_IND_ 3 | CHR_CHG_TRAN_SEQ_NO_3 | CHR_CHRG_CODE_4 | CHR_CHG_RECORD_STATUS_4 +| CHR_CHG_TRAN_LVL_IND_4 | CHR_CHG_TRAN_SEQ_NO_ 4 | CHR_CHRG_CODE_5 | CHR_CHG_RECORD_STATUS_5 | CHR_CHG_TRAN_LVL_IND_5 + | CHR_CHG_TRAN_SEQ_NO_5 | CHR_CHRG_CODE_6 | CH R_CHG_RECORD_STATUS_6 | CHR_CHG_TRAN_LVL_IND_6 | CHR_CHG_TRAN_SEQ_NO_6 + | CHR_CHRG_CODE_7 | CHR_CHG_RECORD_STATUS_7 | CHR_CHG_TRAN_LVL_IND_7 | CHR_CHG_TRAN_SEQ_NO_7 | CHR_CHRG_CODE_8 | CHR +_CHG_RECORD_STATUS_8 | CHR_CHG_TRAN_LVL_IND_8 | CHR_CHG_TRAN_SEQ_NO_8 | CHR_CHRG_CODE_9 | CHR_CHG_RECORD_STATUS_9 | C +HR_CHG_TRAN_LVL_IND_9 | CHR_CHG_TRAN_SEQ_NO_9 | CHR_CHRG_CODE_10 | CHR_CHG_RECORD_STATUS_10 | CHR_CHG_TRAN_LVL_IND_10 + | CHR_CHG_TRAN_SEQ_NO_10 | CHR_CHRG_CODE_11 | CHR_CHG_RECORD_STATUS_11 | CHR_CHG_TRAN_LVL_IND_11 | CHR_CHG_TRAN_SEQ_ +NO_11 | CHR_CHRG_CODE_12 | CHR_CHG_RECORD_STATU S_12 | CHR_CHG_TRAN_LVL_IND_12 | CHR_CHG_TRAN_SEQ_NO_12 | CHR_CHRG_COD +E_13 | CHR_CHG_RECORD_STATUS_13 | CHR_CHG_TRAN_ LVL_IND_13 | CHR_CHG_TRAN_SEQ_NO_13 | CHR_CHRG_CODE_14 | CHR_CHG_RECOR +D_STATUS_14 | CHR_CHG_TRAN_LVL_IND_14 | CHR_CHG _TRAN_SEQ_NO_14 | CHR_CHRG_CODE_15 | CHR_CHG_RECORD_STATUS_15 | CHR_CH +G_TRAN_LVL_IND_15 | CHR_CHG_TRAN_SEQ_NO_15 | CH R_CHRG_CODE_16 | CHR_CHG_RECORD_STATUS_16 | CHR_CHG_TRAN_LVL_IND_16 | +CHR_CHG_TRAN_SEQ_NO_16 | CHR_CHRG_CODE_17 | CHR _CHG_RECORD_STATUS_17 | CHR_CHG_TRAN_LVL_IND_17 | CHR_CHG_TRAN_SEQ_NO_ +17 | CHR_CHRG_CODE_18 | CHR_CHG_RECORD_STATUS_1 8 | CHR_CHG_TRAN_LVL_IND_18 | CHR_CHG_TRAN_SEQ_NO_18 | CHR_CHRG_CODE_1 +9 | CHR_CHG_RECORD_STATUS_19 | CHR_CHG_TRAN_LVL _IND_19 | CHR_CHG_TRAN_SEQ_NO_19 | CHR_CHRG_CODE_20 | CHR_CHG_RECORD_S +TATUS_20 | CHR_CHG_TRAN_LVL_IND_20 | CHR_CHG_TR AN_SEQ_NO_20 | ', '1.0', 'mark', 'insert', '1.2344', 'text', ' ', '1.2344' ];
      Looks like I may have to parse the Dumper's output to get the data loaded back in the same format - Ah well... Continuing to beat my head against the desk.

      Thanks again.
      -Michael