deep.ocean has asked for the wisdom of the Perl Monks concerning the following question:

This command run in command promt window : C:\stanford-ner-2009-01-16 > perl -ne 'chomp; print "$_\tO\n"' jane-austen-emma-ch1.tok > jane-austen-emma-ch1.tsv Can't find string terminator " ' " anywhere before EOF at line 1 why the command Can't find string terminator ? Thanks

Replies are listed 'Best First'.
Re: Can't find string teminator
by kennethk (Abbot) on Apr 06, 2010 at 16:03 UTC
    This is a shell problem, not a Perl issue. cmd.exe uses double quotes as string delimiters. You can avoid this with Perl by using other Quote and Quote like Operators. For example, this will likely work (assuming there are no other issues with your command):

    perl -ne "chomp; print qq{$_\tO\n}" jane-austen-emma-ch1.tok > jane-austen-emma-ch1.tsv

      Thank a lot
Re: Can't find string teminator
by Corion (Patriarch) on Apr 06, 2010 at 16:03 UTC

    cmd.exe uses double quotes for parameter quoting, not single quotes. So you will have to remove all usage of double quotes from within your snippet (hint: replace "..." by qq(...)) and put them in place of the single quotes surrounding your snippet.

      Thank you
Re: Can't find string teminator
by ikegami (Patriarch) on Apr 06, 2010 at 16:28 UTC

    Your system uses double quotes for arguments, not single quotes. The arguments you are passing to perl:

    1: -ne 2: 'chomp; <-- argument to (-e)xecute 3: print <-- $ARGV[0] 4: "$_\tO\n"' <-- $ARGV[1] 5: jane-austen-emma-ch1.tok <-- $ARGV[2]
      Thank u
Re: Can't find string teminator
by cdarke (Prior) on Apr 06, 2010 at 16:33 UTC
    You have to escape the embedded double quotes on cmd.exe:
    perl -ne "chomp; print \"$_\tO\n\""
    and on PowerShell use single outer quotes:
    perl -ne 'chomp; print \"$_\tO\n\"'
    Yet in both cases the embedded quotes still need to be escaped (you would have thought it was not needed on PowerShell, wouldn't you?)
      Thank U
Re: Can't find string teminator
by jethro (Monsignor) on Apr 06, 2010 at 16:09 UTC
    perl -ne 'chomp; print "$_\tO\n"' test.txt > bla.txt

    works very well here on a linux command line. Maybe it is windows or you had a typo.

    PS: Please use code tags for your code

      Thank You