in reply to Renaming Files

One of your problems seems to be
'C:\\temp'

you do not need to escape backslashes in strings enclosed in single-quotes; I may be wrong, though, I'm windows free since 2.5 years now.

On another note: If the program exits with such a clear error-message, believe what it says and try to debug it the old way: just print out where you are and what the variable-values are.
You'll see that your understanding of what programming is and what programs you've written actualy do, increases a lot if you take a closer look yourself.

As a second note:
The programm seems to be overly complicated for such a simple task, maybe you should google around a bit on this subject; learning by doing is a Good Thing(TM), but The-Right-Tool-For-The-Right-Job(tm) too ;-)

Now to the solution: Change line ~43

} elsif (rename "$newdir/$get_files", "$newdir/$newfile") {

hth,
regards,
tomte


Replies are listed 'Best First'.
Re: Re: Renaming Files
by thor (Priest) on Feb 20, 2003 at 00:08 UTC
    eep! You most certainly do need to escape backslashes, whether in single quotes or not. This is because the backslash is the escape character. If you didn't have to escape backslashes, how would you represent a newline from within a single-quoted string? perl is smart, but not that smart.

    thor

      my perl seems to be...
      #!/usr/bin/perl -w print 'test\n'; print "test\n"; __END__ test\ntest

      Update:

      perldoc perldata

      String literals are usually delimited by either single or double quotes. They work much like quotes in the standard Unix shells: double-quoted string literals are subject to backslash and variable substitution; single-quoted strings are not (except for "\'" and "\\").

      regards,
      tomte


        and mine doesn't
        #!perl -w print '\' __END__ Can't find string terminator "'" anywhere before EOF at C:\test.pl lin +e3
        ...because it thinks I'm trying to escape a single quote. So, single quotes obviously do some sort of backslash interpolation. Your original point was that he didn't have to escape the \ in "c:\path\to\something". I think of it this way: nothing interpolates within single quotes, including escape sequences. If you do something like $string = 'some string\t\n', the result will interpolate to the right thing in double quotes. Now, that having been said, one can embolden perldata another way:
        String literals are usually delimited by either single or double quotes. They work much like quotes in the standard Unix shells: double-quoted string literals are subject to backslash and variable substitution; single-quoted strings are not (except for "\'" and "\\")
        I concede that I was mistaken. My apologies.

        thor