i am taking one variable
$var2="\\hydfs00\PUBLIC1\DEV\pkumar\ITT_TEST_BUILD\CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated";
and want to change it to
$var2="//hydfs00/PUBLIC1/DEV/pkumar/ITT_TEST_BUILD/CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated";
I’m using syntax $var2 =~ s/\\/\//g; for changing this. but the output is coming like /hydfs00PUBLIC1DEVpkumarITT_TEST_BUILDCS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated
please help me out.
"\\hydfs00\PUBLIC1\DEV\pkumar\ITT_TEST_BUILD\CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated"is a mistake:It evaluates to
\hydfs00PUBLIC1DEVpkumarITT_TEST_BUILDCS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated.You want to single-quote the string in order to restrict backslash-escaping to backslashes and single quotes only.
'\\hydfs00\PUBLIC1\DEV\pkumar\ITT_TEST_BUILD\CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated'evaluates to\hydfs00\PUBLIC1\DEV\pkumar\ITT_TEST_BUILD\CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated.Let’s properly escape the backslashes at the beginning so we get two backslashes.
'\\\\hydfs00\PUBLIC1\DEV\pkumar\ITT_TEST_BUILD\CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated'evaluates to\\hydfs00\PUBLIC1\DEV\pkumar\ITT_TEST_BUILD\CS2.1_PROD_TEST_40550_LG_LC_Java_sp36_obfuscated. This is the string you intended.Now we can operate on the value.
This is all newbie stuff. Go learn the language, read a book or two.