Newboy02

Q: I cannot get a Perl script to run

I cannot get a Perl script to run - the compiler will not even accept double quotes

iMac with Retina 5K display, OS X El Capitan (10.11.6)

Posted on Aug 20, 2016 10:51 AM

Close

Q: I cannot get a Perl script to run

  • All replies
  • Helpful answers

  • by etresoft,

    etresoft etresoft Aug 20, 2016 10:57 AM in response to Newboy02
    Level 7 (29,051 points)
    Aug 20, 2016 10:57 AM in response to Newboy02

    Hello Newboy02,

    You are going to have to provide a few more details than that. What is this Perl script? What do you mean "the compiler will not even accept double quotes"? There is no compiler with Perl.

  • by Newboy02,

    Newboy02 Newboy02 Aug 21, 2016 12:01 AM in response to etresoft
    Level 1 (9 points)
    Desktops
    Aug 21, 2016 12:01 AM in response to etresoft

    Into a *.pl file I write ' open (REC,">>save.txt"); ' and get the response that there is an Unrecognized character \xE2; at the first double quote.  Sorry to mention compiler rather that parser.

     

    In fact the parser will not accept double quotes (i.e.. ") in any line and the simple  ' print "Hello World"; is objected to also.  Oddly the open file line I mention will pass if I use back ticks instead and the file is created. But using a line such as ' print REC"hello"; ' is not accepted whether using double or single quotes and with back ticks it is parsed but nothing gets written to the file.

     

    In short the Perl5 is unusable?

  • by BobHarris,

    BobHarris BobHarris Aug 21, 2016 7:35 AM in response to Newboy02
    Level 6 (19,272 points)
    Mac OS X
    Aug 21, 2016 7:35 AM in response to Newboy02

    Use a "REAL" text editor.  I suggest you try TextWrangler (free download) if you want to use a GUI based text editor

    <http://www.barebones.com/products/textwrangler/>

     

    If you do not want to download a very good text editor, then use 'nano' from a terminal session, or vim, or emacs, or if you must use TextEdit, make sure you change the file to a Plain Text File before you save it.

     

    PS.  You perl statement works just fine on my Mac, when I put it into a file using

    echo 'open (REC,">>save.txt");' >tmp.pl

    perl tmp.pl

    # no error reported

    echo $?

    0

    # completion status was success

  • by etresoft,

    etresoft etresoft Aug 21, 2016 9:07 AM in response to Newboy02
    Level 7 (29,051 points)
    Aug 21, 2016 9:07 AM in response to Newboy02

    Hello again Newboy02,

    it sounds like you are using smart quotes. Follow Bob's advice and that should fix it.

  • by Newboy02,Solvedanswer

    Newboy02 Newboy02 Aug 21, 2016 9:27 AM in response to Newboy02
    Level 1 (9 points)
    Desktops
    Aug 21, 2016 9:27 AM in response to Newboy02

    Thanks to both of you. A quick trial shows promise.  I really though plain text would have been a default for a 'lite' text editor - ah well!

  • by BobHarris,Helpful

    BobHarris BobHarris Aug 21, 2016 11:57 AM in response to Newboy02
    Level 6 (19,272 points)
    Mac OS X
    Aug 21, 2016 11:57 AM in response to Newboy02

    Nope.  TextEdit is a lite Word Processor, that can generate plain text files, if you convert the file via the TextEdit -> Format -> Make Plain Text menu item.

     

    Easier to actually use a full time real text editor, as mentioned above.