in reply to Direct to spreadsheet

A pretty light weight way of doing it is to replace your print TXT lines with push @data, and your while (<TXT>) with for (@data).

You need to add a my @data; line and remove all the TXT related stuff.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Direct to spreadsheet
by Anonymous Monk on Jan 23, 2006 at 13:56 UTC
    I tried this but must be doing something wrong. I think the problem surrounds this statement.
    for (@data2) { chomp; if( m[/\*] ) { $_ .= <TXT> until m[\*/]; s[ \s? / \* .+? \* / \s? ][]smgx; # Get rid of comments, we ar +en't interested in checking comment conten t chomp; }
    I'm not sure how to change this (the TXT bit) to reflect the fact I'm using an array instead ?

      Sorry, didn't notice that wrinkle the first time through. <TXT> needs to disappear - you are no longer using a file remember. I'd rework it to shift the lines out of the array bthus:

      while (@data2) { $_ = shift @data2; if( m[/\*] ) { $_ .= shift @data2 until m[\*/] or ! @data2; s[ \s? / \* .+? \* / \s? ][]smgx; } }

      Note that the chomps are not required because they weren't added to the lines in the array. Note also the check for end of data in the until.


      DWIM is Perl's answer to Gödel