in reply to Re: Direct to spreadsheet
in thread Direct to spreadsheet

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 ?

Replies are listed 'Best First'.
Re^3: Direct to spreadsheet
by GrandFather (Saint) on Jan 23, 2006 at 17:51 UTC

    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