i can't replace the '\' to '/'for example:$sMetaKeywordsfile="C:\somepath\test\test.asp"$sMetaKeywordsfile= ~ s/\\/\//; i want to get "c:/somepath/test/test.asp"Your valuable suggestion will be appreciated.
use something like: $str =~ s#\\#\/#g
$str =~ tr|\\|/|;
$str =~ s|\\|/|g;
use Benchmark;timethese(1000, { substitute => \&do_sub, transliterate => \&do_trans});sub do_sub { my $str = q(); foreach (0..1000) { $str = q(\this\is\a\test\string); $str =~ s|\\|/|g; } return $str;}sub do_trans { my $str = q(); foreach (0..1000) { $str = q(\this\is\a\test\string); $str =~ tr|\\|/|; } return $str;}
Benchmark: timing 1000 iterations of substitute, transliterate...substitute: 2 wallclock secs ( 1.88 usr + 0.01 sys = 1.89 CPU) @ 529.10/s (n=1000)transliterate: 1 wallclock secs ( 0.45 usr + 0.00 sys = 0.45 CPU) @ 2222.22/s (n=1000)