Dizzy74 wrote: > > open(FILE,"F:\\test_db\\Admin\\MINIHI\\DEF\\prog_list.txt"|| die "cant > open file") ; > chomp(@tblname = <FILE>); > open (outfile, ">F:\\test_db\\Admin\\MINIHI\\DEF\\INSERTprog_list.sql"|| > die "cant open file") ; > foreach $progid (@tblname) { > > $progid =~ s/\s+$//; > > print outfile ("insert into ... where program_id = '$progid' > and rownum <=300 ;\n") ; > print "insert into ... where program_id = '$progid' and rownum > <=300 ;\n" ; > > } > close outfile ; > > > #### prog_list.txt example > > name -space-space > name_address -tab-space > name_phone - somekind of whitespace
the chop(EXP) function always remove the last character (or byte if you are dealing with ASCII test only) from the applied EXP or $_ if EXP is omitted. it doesn't care what that character is. it's true that if you happen to have a single space at the end of your string, chop will remove it for you, but if you have many spaces at the end, only one will be removed. the chomp(EXP) function remove the last character from EXP(or $_) only if that character is a newline for your OS. chomp() knows what newline your OS uses so you don't have to worry about it. again, chomp doesn't remove spaces(unless you happen to treat newline and space is the same). to trim spaces, try: $line ="\t\t abcd\t \t\n"; $line =~ /^\s+//; $line =~ /\s+$//; #-- also remove \n print "|$line|"; #-- prints |abcd| without leading or tailing spaces __END__ also, i notice that you use 'outfile' as one of your open file handle. using all lower case is not recommanded because Perl names all of it's functions using lower case. what happen if later version of Perl happen to have a function call 'outfile'? what will the following do then: print outfile "hi"; prints hi to file handle outfile? or prints whatever outfile() return to STDOUT? if you have warning enable like '-w' (which i think you should), Perl will warn you about using all lower case for file handle. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]