A. Sinan Unur said:
(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:
I need a program to rename file name.
so the input to run the program would be
RenameFiles //server1/Folder1/folder2/tester.doc
[program name] [location of file]
program would return:
++server1+Folder1+folder2+tester.doc
....
Have you looked at File::Spec?
Specifically, the 'splitdir' method?
Why using a canon if bow&arrow in the form of a tr/// or y///
would do?
Because I interpreted the question as dealing with path separators,
rather than plain text.
That is, the task is to split path components, and join them using '+'
for each path component.
Using splitdir makes it obvious to the reader of the code.
Also, split dir does the right thing even when the path above, which
looks like a Windows path, is specified using \ rather than /:
use strict;
use warnings;
use File::Spec::Functions 'splitdir';
my @p1 = join('+', splitdir q{//server1/Folder1/folder2/tester.doc});
my @p2 = join('+', splitdir q{\\\\server1\Folder1\folder2\tester.doc});
print "@p1\n@p2\n";
__END__
Using tr/// and y///, one would have to try to special case this, based
on the OS.
Sinan