Re: Rename problem
by Abigail-II (Bishop) on Nov 22, 2002 at 17:29 UTC
|
Perhaps the rename failed. But you never know if you don't
check the return value of rename.
Abigail | [reply] [d/l] |
|
|
Thanks Abigail-II, I actually changed the line but no change in filename or error reported. Is there another way to check the return value
| [reply] |
|
|
What "another way"? You used no way....
A typical way is:
rename ($old, $new) or die "Failed to rename $old to $new: $!\n";
Abigail | [reply] [d/l] |
|
|
|
|
Re: Rename problem
by tadman (Prior) on Nov 22, 2002 at 17:20 UTC
|
| [reply] [d/l] |
|
|
Thats fine but probably in a fit of frustration I created the variable in question. As stupid as that sounds.
| [reply] |
|
|
Does the function return an error? Does your rename name have any unusual characters in it? Are you changing directories, for example?
| [reply] |
|
|
|
|
|
Re: Rename problem
by fruiture (Curate) on Nov 22, 2002 at 17:11 UTC
|
What contents does $old_title have? The Code is nearly allright: It renames 'archive.txt' to whatever is in $the_old_title and $the_old title is wahetevr was in $old_title with appended '.shtml'. You can rely on that.
What is actually happening?
Please check `perldoc -q "quoting.*vars"`!
--
http://fruiture.de
| [reply] |
|
|
What contents does $old_title have?
$old_title is just a string of chars.
What is actually happening?
the resulting name is incorrect. It is missing the file extension ie .shtml
| [reply] |
Re: Rename problem
by John M. Dlugosz (Monsignor) on Nov 22, 2002 at 20:48 UTC
|
Try coding a rename with the actual name on the right, as opposed to variables and computation. If that works, you know the rename itself is OK and the problem is with the computation of the value. If that still doesn't work, the problem is with the rename, not with Perl. Perhaps file system issues... try it and report back, as this will cut down the problem size.
—John | [reply] |
Re: Rename problem
by arrow (Friar) on Nov 22, 2002 at 21:49 UTC
|
What you might want to try is my $the_old_title = "$old_title"."\.shtml"; Then do rename("archive.txt","$the_old_title"); Tell us what happens
Cheers | [reply] [d/l] [select] |
|
|
That was it..
Thanks so much for your help. I hope I can return the favor sometime.
| [reply] |
Re: Rename problem
by Dr. Mu (Hermit) on Nov 23, 2002 at 00:04 UTC
|
Okay this is a long shot. I only bring it up because, in a frustrated and fatigued state, I've done the same thing. After each failed attempt, did you remember to change the errant file name back to "archive.txt", before the next try? | [reply] |