in reply to Re^2: wanting to make a file of strings usable by SQL
in thread wanting to make a file of strings usable by SQL

Try this

#! perl -slw use strict; chomp( $_ = <DATA> ); print "($_,"; while( <DATA> ) { chomp; $_ = "'$_'"; last if eof(DATA); print "$_,"; } print "$_)"; __DATA__ one two three four

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: wanting to make a file of strings usable by SQL
by Aristotle (Chancellor) on Dec 27, 2005 at 04:47 UTC

    Ugh. That is definitely much less clear than his sed script. Without knowing what it’s supposed to do it’ll take blinking and staring to figure it out.

    Rule of thumb: eof is about as meritorious as goto.

    Makeshifts last the longest.

      Rule of thumb: eof is about as meritorious as goto.

      In a word. Balderdash :)

      $. Is that the commercial arm of /.?

      Quite how you can claim that a comparison using eof is less clear than one using $. is quite beyond me.

      Most anyone who has programmed in any C-like language, and a whole host of others, will immediately recognise the concept and purpose of the function eof.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        And yet, look at your code. Does that look readable to you? Honestly?

        There’s someone more prominent than me who said that function is almost always a bad choice. Because it is. The idea of eof is that you’re peeking ahead in the stream to see what will happen next. It is not at all comparable to testing $. in that sense.

        Makeshifts last the longest.