in reply to Problem with string manipulation

This should do the trick:
open(IN, "<", "print_tools.txt") or die "Cannot open print_tools.txt f +or reading, $!"; while(<IN>){ chomp; s/^\s+//; s/\s+{.*}//; print "modelCombo.addItem($_);\n"; }

Updated to fully satisfy OP's requirements.

Replies are listed 'Best First'.
Re: Re: Problem with string manipulation
by webengr (Pilgrim) on Jan 03, 2003 at 23:18 UTC
    Or, omitting the substitutions and keeping the original string intact,
    open( IN, "<", "print_tools.txt" )or die("Cannot open print_tools.txt +for reading: $!" ); while(<IN>) { /("[^"]+")/; print "modelCombo.addItem($1);\n"; } close IN;

    PCS
Re: Re: Problem with string manipulation
by Anonymous Monk on Jan 03, 2003 at 22:45 UTC
    I still got space after the string otherwise its ok. thanks. --kirk123