inplace edit error message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news.verizon.net

    inplace edit error message

    I'm working through the examples in Jeffrey E. F. Friedl's book 'Mastering
    Regular Expressions, 2nd Ed.'. I'm trying to work the example at the top of
    p. 53, but I'm attempting it in a command prompt window (I'm using Windows
    2000 pro). I enter:
    perl -p -i -e 's/sysread/read/g' substitute.txt

    I get this error message:
    "Can't do inplace edit without backup."

    Any ideas?

    Thanks,
    Al


  • Jim Gibson

    #2
    Re: inplace edit error message

    In article <2EWdb.11826$yU 5.9746@nwrdny01 .gnilink.net>,
    news.verizon.ne t <acadalzo@veriz on.net> wrote:
    [color=blue]
    > I'm working through the examples in Jeffrey E. F. Friedl's book 'Mastering
    > Regular Expressions, 2nd Ed.'. I'm trying to work the example at the top of
    > p. 53, but I'm attempting it in a command prompt window (I'm using Windows
    > 2000 pro). I enter:
    > perl -p -i -e 's/sysread/read/g' substitute.txt
    >
    > I get this error message:
    > "Can't do inplace edit without backup."
    >
    > Any ideas?
    >
    > Thanks,
    > Al
    >
    >[/color]

    Your perl is not letting you overwrite the substitute.txt file. While I
    am not sure why this is so, you should be able to get around this by
    specifying an extension after the -i switch. Perl will then save the
    original file with this extension and write the modified file to the
    original file name (untested):

    perl -p -i '.bak' -e 's/sysread/read/g' substitute.txt

    FYI: the comp.lang.perl news group is obsolete. Try using
    comp.lang.perl. misc in the future.

    Comment

    • Al C.

      #3
      Re: inplace edit error message

      Jim,

      TFYR. It ran without error this time and produced the backup file.
      However, when I opened the substitute.txt file, it was unchanged. I
      expected to see all occurrences of 'sysread' to be changed to 'read'. I'll
      work on it some more. Thanks.
      (And I'll be using the other newsgroup you mentioned).

      Al


      "Jim Gibson" <jgibson@mail.a rc.nasa.gov> wrote in message
      news:2909200313 11419637%jgibso n@mail.arc.nasa .gov...[color=blue]
      > In article <2EWdb.11826$yU 5.9746@nwrdny01 .gnilink.net>,
      > news.verizon.ne t <acadalzo@veriz on.net> wrote:
      >[color=green]
      > > I'm working through the examples in Jeffrey E. F. Friedl's book[/color][/color]
      'Mastering[color=blue][color=green]
      > > Regular Expressions, 2nd Ed.'. I'm trying to work the example at the[/color][/color]
      top of[color=blue][color=green]
      > > p. 53, but I'm attempting it in a command prompt window (I'm using[/color][/color]
      Windows[color=blue][color=green]
      > > 2000 pro). I enter:
      > > perl -p -i -e 's/sysread/read/g' substitute.txt
      > >
      > > I get this error message:
      > > "Can't do inplace edit without backup."
      > >
      > > Any ideas?
      > >
      > > Thanks,
      > > Al
      > >
      > >[/color]
      >
      > Your perl is not letting you overwrite the substitute.txt file. While I
      > am not sure why this is so, you should be able to get around this by
      > specifying an extension after the -i switch. Perl will then save the
      > original file with this extension and write the modified file to the
      > original file name (untested):
      >
      > perl -p -i '.bak' -e 's/sysread/read/g' substitute.txt
      >
      > FYI: the comp.lang.perl news group is obsolete. Try using
      > comp.lang.perl. misc in the future.[/color]


      Comment

      • Eric J. Roode

        #4
        Re: inplace edit error message

        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        "news.verizon.n et" <acadalzo@veriz on.net> wrote in
        news:2EWdb.1182 6$yU5.9746@nwrd ny01.gnilink.ne t:
        [color=blue]
        > I'm working through the examples in Jeffrey E. F. Friedl's book
        > 'Mastering Regular Expressions, 2nd Ed.'. I'm trying to work the
        > example at the top of p. 53, but I'm attempting it in a command prompt
        > window (I'm using Windows 2000 pro). I enter:
        > perl -p -i -e 's/sysread/read/g' substitute.txt
        >
        > I get this error message:
        > "Can't do inplace edit without backup."[/color]

        I have seen this under Windows, since the Windows OS filesystem does not
        have Unix's flexibility when it comes to editing a file in-place.

        You'll have to specify a backup file extension with the -i option.

        For your future reference, comp.lang.perl is a defunct newsgroup. General
        Perl questions should be posted to comp.lang.perl. misc; you'll get a better
        response there.

        - --
        Eric
        $_ = reverse sort $ /. r , qw p ekca lre uJ reh
        ts p , map $ _. $ " , qw e p h tona e and print

        -----BEGIN PGP SIGNATURE-----
        Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

        iQA/AwUBP3q77mPeouI eTNHoEQIpvQCg9s k+wQ994dpbqRFJB tSh1ROLtOYAn2ZY
        65N1CH3bU8n8T6X DVfd5LckO
        =coZf
        -----END PGP SIGNATURE-----

        Comment

        • Jim Gibson

          #5
          Re: inplace edit error message

          In article <2EWdb.11826$yU 5.9746@nwrdny01 .gnilink.net>,
          news.verizon.ne t <acadalzo@veriz on.net> wrote:
          [color=blue]
          > I'm working through the examples in Jeffrey E. F. Friedl's book 'Mastering
          > Regular Expressions, 2nd Ed.'. I'm trying to work the example at the top of
          > p. 53, but I'm attempting it in a command prompt window (I'm using Windows
          > 2000 pro). I enter:
          > perl -p -i -e 's/sysread/read/g' substitute.txt
          >
          > I get this error message:
          > "Can't do inplace edit without backup."
          >
          > Any ideas?
          >
          > Thanks,
          > Al
          >
          >[/color]

          You need to specify a file extension after the -i option so that perl
          has someplace to put the original file:

          perl -p -i '.bak' -e 's/sysread/read/g' substitute.txt

          This newsgroup is defunct. Try comp.lang.perl. misc in the future.

          Comment

          Working...