Loading ...
Sorry, an error occurred while loading the content.

perl one liners

Expand Messages
  • sarveshjangid
    Dear all, i am quite new to perl. I am trying to run this one liner through cmd.exe on windows 2000 perl -e print Matched! if This is my nmulti-line
    Message 1 of 3 , Jul 2, 2007
    • 0 Attachment
      Dear all,
      i am quite new to perl. I am trying to run this one liner through
      cmd.exe on windows 2000
      perl -e 'print "Matched!" if "This is my\nmulti-line string" =~
      /This.*string/;'

      but i am getting this error. Please help!

      Can't find string terminator "'" anywhere before EOF at -e line 1.

      This example one liner has been taken from
      http://www.perl.com/pub/a/2003/06/06/regexps.html

      ********************************************************************
    • bike2ride
      Hi on windows take care of single and double quotes perl -e print Hello, world! n
      Message 2 of 3 , Jul 2, 2007
      • 0 Attachment
        Hi

        on windows take care of single and double quotes

        perl -e "print \"Hello, world!\n\""


        --- In perl-beginner@yahoogroups.com, "sarveshjangid"
        <sarveshjangid@...> wrote:
        >
        > Dear all,
        > i am quite new to perl. I am trying to run this one liner through
        > cmd.exe on windows 2000
        > perl -e 'print "Matched!" if "This is my\nmulti-line string" =~
        > /This.*string/;'
        >
        > but i am getting this error. Please help!
        >
        > Can't find string terminator "'" anywhere before EOF at -e line 1.
        >
        > This example one liner has been taken from
        > http://www.perl.com/pub/a/2003/06/06/regexps.html
        >
        > ********************************************************************
        >
      • Jenda Krynicky
        From: sarveshjangid ... The problem is that cmd.exe doesn t understand the singlequotes as parameter delimiters. You have to
        Message 3 of 3 , Jul 3, 2007
        • 0 Attachment
          From: "sarveshjangid" <sarveshjangid@...>
          > Dear all,
          > i am quite new to perl. I am trying to run this one liner through
          > cmd.exe on windows 2000
          > perl -e 'print "Matched!" if "This is my\nmulti-line string" =~
          > /This.*string/;'
          >
          > but i am getting this error. Please help!
          >
          > Can't find string terminator "'" anywhere before EOF at -e line 1.

          The problem is that cmd.exe doesn't understand the singlequotes as
          parameter delimiters. You have to change the onliner to this:

          perl -e "print 'Matched!' if qq{This is my\nmulti-line string} =~
          /This.*string/;"

          That is there have to be doublequotes around the code and you have to
          use singlequotes of qq{} in place of any doublequotes within the
          code.

          HTH, Jenda

          ===== Jenda@... === http://Jenda.Krynicky.cz =====
          When it comes to wine, women and song, wizards are allowed
          to get drunk and croon as much as they like.
          -- Terry Pratchett in Sourcery
        Your message has been successfully submitted and would be delivered to recipients shortly.