in reply to Appending values to variable.

You could use join

$newpath=join("\",@dirs);

or not use split in the first place and instead replace the slashes directly

$filepath=~s{/}{\\}g;

But note that usually when dealing with filepaths it is better not to manually munge but use the appropriate modules for that (see perldoc perlport and perldoc File::Spec for more).


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan